|
| 1 | +name: nightly |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # At 03:07 |
| 6 | + - cron: '7 3 * * *' |
| 7 | + |
| 8 | +env: |
| 9 | + # We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run a step |
| 10 | + # 'if env.GHCR_USERNAME' != ""', so we copy these to test whether credentials |
| 11 | + # are available before trying to run steps that need them. Like PRs from forks! |
| 12 | + GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }} |
| 13 | + IMAGE_NAME: ghcr.io/external-secrets/kubernetes-external-secrets |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - name: Set up QEMU |
| 23 | + uses: docker/setup-qemu-action@v1 |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v1 |
| 27 | + |
| 28 | + - name: Docker meta |
| 29 | + id: docker_meta |
| 30 | + uses: crazy-max/ghaction-docker-meta@v2 |
| 31 | + with: |
| 32 | + images: ${{ env.IMAGE_NAME }} |
| 33 | + tags: | |
| 34 | + type=schedule,pattern=nightly |
| 35 | +
|
| 36 | + - name: Login to Docker |
| 37 | + uses: docker/login-action@v1 |
| 38 | + if: env.GHCR_USERNAME != '' |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + username: ${{ secrets.GHCR_USERNAME }} |
| 42 | + password: ${{ secrets.GHCR_TOKEN }} |
| 43 | + |
| 44 | + - name: Build nightly |
| 45 | + uses: docker/build-push-action@v2 |
| 46 | + with: |
| 47 | + context: . |
| 48 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 49 | + push: ${{ env.GHCR_USERNAME != '' }} |
| 50 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 51 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 52 | + |
| 53 | + scan: |
| 54 | + needs: build |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Run Trivy vulnerability scanner |
| 58 | + uses: aquasecurity/trivy-action@master |
| 59 | + with: |
| 60 | + image-ref: ${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }} |
| 61 | + format: 'template' |
| 62 | + ignore-unfixed: true |
| 63 | + severity: HIGH,CRITICAL |
| 64 | + template: '@/contrib/sarif.tpl' |
| 65 | + output: 'trivy-results.sarif' |
| 66 | + |
| 67 | + - name: Upload Trivy scan results to GitHub Security tab |
| 68 | + uses: github/codeql-action/upload-sarif@v1 |
| 69 | + with: |
| 70 | + sarif_file: 'trivy-results.sarif' |
0 commit comments