From dafa0e1d5c4a1c5a826dd98e6deb5122be1cab6e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:13:35 +0200 Subject: [PATCH] #43 Create publish job to publish to github container registry on any tag push --- .github/workflows/publish.yml | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7e0f7be --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,78 @@ +name: Publish +description: | + This workflow publishes the Docker image to the GitHub Container Registry and the Helm chart to the appropriate s3 bucket. + It's triggered when a new tag is pushed to the repository, this can either be in main (as a release tag) or in a feature + branch (as a prerelease tag). + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +permissions: + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + NODE_VERSION: 18.17.1 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install packages + run: npm ci + + - name: Build + run: npm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: | + dist + prisma + Dockerfile + .dockerignore + package*.json + + docker-publish: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}