This repository was archived by the owner on Mar 4, 2025. It is now read-only.
Merge pull request #51 from statuscompliance/feature/50-refactor_cata… #5
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 Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| tags: | |
| - "*.*.*" | |
| pull_request: | |
| branches: | |
| - develop | |
| - main | |
| types: | |
| - labeled | |
| env: | |
| REGISTRY_IMAGE: ${{ secrets.DOCKER_USERNAME }}/status-frontend | |
| GHCR_IMAGE: ${{ secrets.DOCKER_USERNAME }}/status-frontend | |
| PR_ID: ${{ github.event.pull_request.number }} | |
| TAG: ${{ github.ref_name }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: (github.event.pull_request && github.event.label.name == 'dockerize') || github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Checkout ⬇️ | |
| uses: actions/[email protected] | |
| with: | |
| show-progress: false | |
| - name: Configure QEMU ⚙️ | |
| uses: docker/[email protected] | |
| - name: Configure Docker Buildx ⚙️ | |
| uses: docker/[email protected] | |
| - name: Login to DockerHub 🔑 | |
| uses: docker/[email protected] | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to GitHub Container Registry 🔑 | |
| uses: docker/[email protected] | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push Docker Image | |
| uses: docker/[email protected] | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: | | |
| ${{ startsWith(github.ref, 'refs/tags/') && format('{0}:{1}', env.REGISTRY_IMAGE, env.TAG) || '' }} | |
| ${{ github.ref == 'refs/heads/main' && format('{0}:latest', env.REGISTRY_IMAGE) || '' }} | |
| ${{ github.ref == 'refs/heads/develop' && format('{0}:develop', env.REGISTRY_IMAGE) || '' }} | |
| ${{ github.event_name == 'pull_request' && format('{0}:PR.{1}', env.REGISTRY_IMAGE, env.PR_ID) || '' }} | |
| - name: Build and Push Ghcr Image | |
| uses: docker/[email protected] | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: | | |
| ${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}:{1}', env.GHCR_IMAGE, env.TAG) || '' }} | |
| ${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}:latest', env.GHCR_IMAGE) || '' }} | |
| ${{ github.event_name == 'pull_request' && format('ghcr.io/{0}:PR.{1}', env.GHCR_IMAGE, env.PR_ID) || '' }} |