Docker Image #1433
Workflow file for this run
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: Docker Image | |
| on: | |
| schedule: | |
| - cron: "0 11 * * *" # everyday at 11am | |
| push: | |
| branches: ["**"] | |
| tags: ["v*.*.*"] | |
| env: | |
| platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
| jobs: | |
| main: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| # Docker Hub credentials are not available for pull requests and Dependabot runs | |
| publish: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }} | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v7 | |
| - name: Set imageName based on the repository name | |
| id: step_one | |
| run: | | |
| imageName="${GITHUB_REPOSITORY/docker-/}" | |
| echo $imageName | |
| echo "imageName=$imageName" >> $GITHUB_ENV | |
| - name: Docker meta | |
| id: docker_meta | |
| uses: crazy-max/ghaction-docker-meta@v6 | |
| with: | |
| images: ${{ env.imageName }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| if: env.publish == 'true' | |
| uses: docker/login-action@v4.6.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Buildx cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ github.workspace }}/cache | |
| key: ${{ runner.os }}-docker-${{ hashfiles('cache/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-docker | |
| - name: Build and push | |
| id: docker_build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| platforms: ${{ env.publish == 'true' && env.platforms || 'linux/amd64' }} | |
| push: ${{ env.publish == 'true' }} | |
| load: ${{ env.publish != 'true' }} | |
| tags: ${{ steps.docker_meta.outputs.tags }} | |
| labels: ${{ steps.docker_meta.outputs.labels }} | |
| cache-from: type=local,src=${{ github.workspace }}/cache | |
| cache-to: type=local,dest=${{ github.workspace }}/cache | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@v0.36.0 | |
| with: | |
| image-ref: ${{ env.imageName }}:${{ steps.docker_meta.outputs.version }} | |
| format: "template" | |
| template: "@/contrib/sarif.tpl" | |
| output: "trivy-results.sarif" | |
| - name: Upload Trivy scan results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v4.37.9 | |
| with: | |
| sarif_file: "trivy-results.sarif" |