Docker Image #1144
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 | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v6 | |
| - 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@v5 | |
| with: | |
| images: ${{ env.imageName }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Buildx cache | |
| uses: actions/cache@v5 | |
| 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@v6 | |
| with: | |
| platforms: ${{ env.platforms }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| 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/[email protected] | |
| 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 | |
| with: | |
| sarif_file: "trivy-results.sarif" |