This repository was archived by the owner on Mar 5, 2026. It is now read-only.
Merge pull request #39 from Johnr24/dependabot/npm_and_yarn/fs-extra-… #173
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Docker Images | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ 'v*.*.*' ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| # Use github.repository as the image name (organization/repo) | |
| REGISTRY: ghcr.io | |
| ORG_NAME: ${{ github.repository_owner }} | |
| jobs: | |
| build: | |
| name: Build and Push Docker images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| # This is needed for action/stale | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Get git tag | |
| - name: Get git tag | |
| id: get_tag | |
| run: | | |
| if [ ${{ github.ref }} = refs/heads/main ]; then | |
| echo "tag=$(git describe --tags --abbrev=0 2>/dev/null || echo 'dev')" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=$(git describe --tags --abbrev=0 2>/dev/null || echo 'dev')" >> $GITHUB_OUTPUT | |
| fi | |
| # Set up QEMU for multi-architecture builds | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| # Login to GitHub Container Registry | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Extract metadata for Docker images | |
| - name: Extract Docker metadata for Frontend | |
| id: meta-frontend | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.ORG_NAME }}/colourstream-frontend | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
| - name: Extract Docker metadata for Backend | |
| id: meta-backend | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.ORG_NAME }}/colourstream-backend | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
| # Set up Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Build and push Frontend Docker image | |
| - name: Build and push Frontend Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./frontend | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta-frontend.outputs.tags }} | |
| labels: ${{ steps.meta-frontend.outputs.labels }} | |
| build-args: | | |
| REACT_APP_GIT_TAG=${{ steps.get_tag.outputs.tag }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # Build and push Backend Docker image | |
| - name: Build and push Backend Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta-backend.outputs.tags }} | |
| labels: ${{ steps.meta-backend.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # Echo image references for reference | |
| - name: Print image references | |
| run: | | |
| echo "Frontend image: ${{ steps.meta-frontend.outputs.tags }}" | |
| echo "Backend image: ${{ steps.meta-backend.outputs.tags }}" |