Skip to content

Commit

Permalink
Merge pull request #12 from Dan6erbond/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan6erbond authored May 9, 2023
2 parents efa120b + c846fdc commit 09c4eeb
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 183 deletions.
52 changes: 27 additions & 25 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,47 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME_FRONTEND: ${{ github.repository }}-frontend
IMAGE_NAME_SERVER: ${{ github.repository }}-server

jobs:
build-and-push-image:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
image:
- ${{ github.repository }}-frontend
- ${{ github.repository }}-server
include:
- image: ${{ github.repository }}-frontend
context: "."
- image: ${{ github.repository }}-server
context: "server"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
- name: Extract frontend metadata (tags, labels) for Docker
id: meta-frontend
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}
- name: Build and push frontend Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
images: ${{ env.REGISTRY }}/${{ matrix.image }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
context: ${{ matrix.context }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
- name: Extract server metadata (tags, labels) for Docker
id: meta-server
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_SERVER }}
- name: Build and push server Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: server
push: true
tags: ${{ steps.meta-server.outputs.tags }}
labels: ${{ steps.meta-server.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
80 changes: 43 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ permissions:
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -36,53 +38,57 @@ jobs:
with:
body_path: GITHUB_CHANGELOG.md
tag_name: ${{ steps.release.outputs.version }}
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- release
strategy:
fail-fast: false
matrix:
image:
- ${{ github.repository }}-frontend
- ${{ github.repository }}-server
include:
- image: ${{ github.repository }}-frontend
context: "."
- image: ${{ github.repository }}-server
context: "server"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta-frontend
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}
- name: Lowercase package
id: tags1-frontend
uses: ASzc/change-string-case-action@v1
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}:${{ steps.release.outputs.version }}
- name: Lowercase package
id: tags2-frontend
uses: ASzc/change-string-case-action@v1
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}:latest
- name: Build and push frontend Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.tags1-frontend.outputs.lowercase }},${{ steps.tags2-frontend.outputs.lowercase }}
labels: ${{ steps.meta-frontend.outputs.labels }}
- name: Extract metadata (tags, labels) for Docker
id: meta-server
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_SERVER }}
- name: Lowercase package
id: tags1-server
images: ${{ env.REGISTRY }}/${{ matrix.image }}
- name: Lowercase package (version)
id: tags1
uses: ASzc/change-string-case-action@v1
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_SERVER }}:${{ steps.release.outputs.version }}
- name: Lowercase package
id: tags2-server
string: ${{ env.REGISTRY }}/${{ matrix.image }}:${{ needs.release.outputs.version }}
- name: Lowercase package (latest)
id: tags2
uses: ASzc/change-string-case-action@v1
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_SERVER }}:latest
- name: Build and push server Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
string: ${{ env.REGISTRY }}/${{ matrix.image }}:latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: server
context: ${{ matrix.context }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags1-server.outputs.lowercase }},${{ steps.tags2-server.outputs.lowercase }}
labels: ${{ steps.meta-server.outputs.labels }}
tags: ${{ steps.tags1.outputs.lowercase }},${{ steps.tags2.outputs.lowercase }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
if [ -f yarn.lock ]; then yarn --frozen-lockfile --network-timeout 600000; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
Expand Down
Loading

0 comments on commit 09c4eeb

Please sign in to comment.