|
| 1 | +name: Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 18 * * *" # everyday at 6pm |
| 6 | + push: |
| 7 | + branches: ["**"] |
| 8 | + tags: ["v*.*.*"] |
| 9 | + |
| 10 | +env: |
| 11 | + platforms: linux/amd64 |
| 12 | + |
| 13 | +jobs: |
| 14 | + main: |
| 15 | + runs-on: ubuntu-20.04 |
| 16 | + timeout-minutes: 30 |
| 17 | + steps: |
| 18 | + - name: Check out the repo |
| 19 | + uses: actions/checkout@v2 |
| 20 | + - name: Set imageName based on the repository name |
| 21 | + id: step_one |
| 22 | + run: | |
| 23 | + imageName="${GITHUB_REPOSITORY/docker-/}" |
| 24 | + echo $imageName |
| 25 | + echo "imageName=$imageName" >> $GITHUB_ENV |
| 26 | + - name: Docker meta |
| 27 | + id: docker_meta |
| 28 | + uses: crazy-max/ghaction-docker-meta@v1 |
| 29 | + with: |
| 30 | + images: ${{ env.imageName }} |
| 31 | + - name: Set up QEMU |
| 32 | + uses: docker/setup-qemu-action@v1 |
| 33 | + - name: Set up Docker Buildx |
| 34 | + uses: docker/setup-buildx-action@v1 |
| 35 | + - name: Login to Harbor |
| 36 | + uses: docker/login-action@v1 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 39 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 40 | + - name: Buildx cache |
| 41 | + uses: actions/cache@v1 |
| 42 | + with: |
| 43 | + path: ${{ github.workspace }}/cache |
| 44 | + key: ${{ runner.os }}-docker-${{ hashfiles('cache/**') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-docker |
| 47 | + - name: Build and push |
| 48 | + id: docker_build |
| 49 | + uses: docker/build-push-action@v2 |
| 50 | + with: |
| 51 | + platforms: ${{ env.platforms }} |
| 52 | + push: ${{ github.event_name != 'pull_request' }} |
| 53 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 54 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 55 | + cache-from: type=local,src=${{ github.workspace }}/cache |
| 56 | + cache-to: type=local,dest=${{ github.workspace }}/cache |
| 57 | + # - name: Run Trivy vulnerability scanner |
| 58 | + # uses: aquasecurity/trivy-action@master |
| 59 | + # with: |
| 60 | + # image-ref: ${{ env.imageName }}:${{ steps.docker_meta.outputs.version }} |
| 61 | + # format: "template" |
| 62 | + # template: "@/contrib/sarif.tpl" |
| 63 | + # output: "trivy-results.sarif" |
| 64 | + # - name: Upload Trivy scan results to GitHub Security tab |
| 65 | + # uses: github/codeql-action/upload-sarif@v1 |
| 66 | + # with: |
| 67 | + # sarif_file: "trivy-results.sarif" |
0 commit comments