|
| 1 | +name: Build and Push Docker Image For nginx-utils Container |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | + packages: write |
| 5 | + actions: write |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [created] |
| 9 | + |
| 10 | +env: |
| 11 | + RELEASE_VERSION: ${{ github.event.release.tag_name }} |
| 12 | +jobs: |
| 13 | + run-on-release: |
| 14 | + if: endsWith(github.event.release.tag_name, '-docker') |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Set Release Version |
| 18 | + run: echo "RELEASE_VERSION=${RELEASE_VERSION%-docker}" >> $GITHUB_ENV |
| 19 | + |
| 20 | + - name: Starting Release Build |
| 21 | + run: echo "Starting Release Build for ${RELEASE_VERSION}" |
| 22 | + |
| 23 | + - name: Checkout code |
| 24 | + |
| 25 | + |
| 26 | + - name: List repository files |
| 27 | + run: ls -R .; pwd |
| 28 | + - name: Set up Docker Buildx |
| 29 | + |
| 30 | + |
| 31 | + - name: Log in to GitHub Container Registry |
| 32 | + |
| 33 | + with: |
| 34 | + registry: ghcr.io |
| 35 | + username: ${{ github.repository_owner }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + - name: Build and push Docker image |
| 38 | + |
| 39 | + with: |
| 40 | + context: . |
| 41 | + file: nginx-utils/Dockerfile |
| 42 | + push: true |
| 43 | + platforms: linux/amd64,linux/arm64 |
| 44 | + tags: | |
| 45 | + ghcr.io/nginx/nginx-utils:${{ env.RELEASE_VERSION }} |
| 46 | + ghcr.io/nginx/nginx-utils:latest |
| 47 | +
|
| 48 | + - name: Install Trivy and scan image for vulnerabilities |
| 49 | + uses: aquasecurity/[email protected] |
| 50 | + |
| 51 | + with: |
| 52 | + image-ref: ghcr.io/${{ github.repository_owner }}/nginx-utils:latest |
| 53 | + format: json |
| 54 | + output: vuln-report.json |
| 55 | + |
| 56 | + - name: Upload Vulnerability Report |
| 57 | + |
| 58 | + with: |
| 59 | + name: vuln-report |
| 60 | + path: vuln-report.json |
| 61 | + |
| 62 | + - name: Update Release Notes with Docker Image Info |
| 63 | + |
| 64 | + with: |
| 65 | + tag_name: ${{ github.event.release.tag_name }} |
| 66 | + body: | |
| 67 | + ## Docker Image |
| 68 | + The Docker image for this release can be pulled using: |
| 69 | +
|
| 70 | + ``` |
| 71 | + docker pull ghcr.io/${{ github.repository_owner }}/nginx-utils:${{ github.event.release.tag_name }} |
| 72 | + ``` |
| 73 | +
|
| 74 | + Or use the `latest` tag: |
| 75 | +
|
| 76 | + ``` |
| 77 | + docker pull ghcr.io/${{ github.repository_owner }}/nginx-utils:latest |
| 78 | + ``` |
0 commit comments