Docker Image #710
This file contains 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 15 * * *" # everyday at 3pm | |
push: | |
branches: ["**"] | |
tags: ["v*.*.*"] | |
env: | |
platforms: linux/amd64 | |
jobs: | |
main: | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 30 | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- 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: docker/metadata-action@v4 | |
with: | |
images: ${{ env.imageName }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Harbor | |
uses: docker/#-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# - name: Buildx cache | |
# uses: actions/cache@v3 | |
# 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@v4 | |
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 | |
# temporarily disabled until https://github.com/aquasecurity/trivy-action/issues/22 is resolved | |
# - name: Run Trivy vulnerability scanner | |
# uses: aquasecurity/trivy-action@master | |
# 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@v1 | |
# with: | |
# sarif_file: "trivy-results.sarif" |