| name: Docker |
| |
| on: |
| workflow_dispatch: |
| workflow_call: |
| push: |
| branches: [ "disabled" ] |
| pull_request: |
| branches: [ "disabled" ] |
| |
| jobs: |
| |
| build: |
| runs-on: ubuntu-latest |
| permissions: |
| contents: read |
| packages: write |
| # This is used to complete the identity challenge |
| # with sigstore/fulcio when running outside of PRs. |
| id-token: write |
| |
| steps: |
| - name: Checkout repository |
| uses: actions/checkout@v4 |
| |
| - name: Run linter |
| uses: hadolint/hadolint-action@v3.1.0 |
| with: |
| recursive: true |
| ignore: DL3018 |
| |
| # Workaround: https://github.com/docker/build-push-action/issues/461 |
| - name: Setup Docker buildx |
| uses: docker/setup-buildx-action@v3.0.0 |
| |
| - name: Log in to Docker Hub |
| if: github.event_name != 'pull_request' |
| uses: docker/login-action@v3.0.0 |
| with: |
| username: ${{ secrets.DOCKERHUB_USERNAME }} |
| password: ${{ secrets.DOCKERHUB_TOKEN }} |
| |
| - name: Log in to the Container registry |
| if: github.event_name != 'pull_request' |
| uses: docker/login-action@v3.0.0 |
| with: |
| registry: ghcr.io |
| username: ${{ github.actor }} |
| password: ${{ secrets.GITHUB_TOKEN }} |
| |
| # Extract metadata (tags, labels) for Docker |
| # https://github.com/docker/metadata-action |
| - name: Extract Docker metadata |
| id: meta |
| uses: docker/metadata-action@v5.5.0 |
| with: |
| images: | |
| ${{ github.repository }} |
| ghcr.io/${{ github.repository }} |
| |
| # Build and push Docker image with Buildx (don't push on PR) |
| # https://github.com/docker/build-push-action |
| - name: Build and push Docker image |
| id: build-and-push |
| uses: docker/build-push-action@v5.1.0 |
| with: |
| context: . |
| push: ${{ github.event_name != 'pull_request' }} |
| tags: ${{ steps.meta.outputs.tags }} |
| labels: ${{ steps.meta.outputs.labels }} |
| platforms: linux/amd64 |
| #platforms: linux/amd64,linux/arm/v7,linux/arm/v6 |
| no-cache: true |