This repository was archived by the owner on Mar 4, 2025. It is now read-only.
conf(ci): Improve job execution #4
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 | |
| 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' | |
| 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: 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) || '' }} |