diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index c9b2a41..af3f16d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,5 +1,4 @@ name: CI/CD - on: push: branches: [master] @@ -7,38 +6,55 @@ on: workflow_dispatch: schedule: - cron: '23 5 * * 1' - permissions: contents: read - +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + checks: + runs-on: ubuntu-24.04 + outputs: + tags: ${{ steps.tags.outputs.tags }} + steps: + - uses: actions/checkout@v7 + - name: Check generated contexts + run: | + docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template + git diff --exit-code + - id: tags + run: echo "tags=$(jq -c '[.builds[].name]' fwd-template.json)" >> "$GITHUB_OUTPUT" build: - runs-on: ubuntu-latest + needs: checks + runs-on: ${{ matrix.platform.runner }} strategy: fail-fast: false matrix: version: [php, proxy, static] - + platform: + - {arch: amd64, runner: ubuntu-24.04} steps: - - name: Checkout code - uses: actions/checkout@v7.0.0 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4.2.0 - - - name: Build - run: | - docker buildx build \ - --pull --no-cache \ - --platform linux/amd64 \ - --output type=docker \ - --tag kooldev/nginx:${{ matrix.version }} \ - ${{ matrix.version }} - - - name: Tests - run: bash tests/smoke.sh "${{ matrix.version }}" "kooldev/nginx:${{ matrix.version }}" - - - name: Scan image + - uses: actions/checkout@v7 + - uses: kool-dev/action/image-build@6a6d04e8d1e1c66afc178e32c7d77d76169c7717 + with: + arch: ${{ matrix.platform.arch }} + - name: Build fresh image + id: image + uses: docker/build-push-action@v7 + with: + context: ${{ matrix.version }} + platforms: linux/${{ matrix.platform.arch }} + pull: true + no-cache: true + load: true + provenance: false + tags: kooldev/nginx:${{ matrix.version }} + - name: Smoke tests + env: + VARIANT: ${{ matrix.version }} + IMAGE: ${{ steps.image.outputs.imageid }} + run: bash tests/smoke.sh "$VARIANT" "$IMAGE" + - name: Scan tested image uses: anchore/scan-action@8576240a41341d866dbd7ebc72cd9fc0ef023f54 # v7.4.2 with: image: kooldev/nginx:${{ matrix.version }} @@ -47,7 +63,6 @@ jobs: only-fixed: false output-format: json output-file: grype-${{ matrix.version }}.json - - name: Retain vulnerability report if: always() uses: actions/upload-artifact@v7.0.2 @@ -55,14 +70,28 @@ jobs: name: grype-${{ matrix.version }} path: grype-${{ matrix.version }}.json if-no-files-found: warn - - - name: Login to DockerHub - uses: docker/login-action@v4.4.0 + - uses: kool-dev/action/image-stage@6a6d04e8d1e1c66afc178e32c7d77d76169c7717 if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-nginx' with: + canonical-repository: kool-dev/docker-nginx + default-branch: master + repository: kooldev/nginx + arch: ${{ matrix.platform.arch }} + group: ${{ matrix.version }} + images: '[{"tag":"${{ matrix.version }}","id":"${{ steps.image.outputs.imageid }}"}]' + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + publish: + needs: [checks, build] + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-nginx' + runs-on: ubuntu-24.04 + steps: + - uses: kool-dev/action/image-publish@6a6d04e8d1e1c66afc178e32c7d77d76169c7717 + with: + canonical-repository: kool-dev/docker-nginx + default-branch: master + repository: kooldev/nginx + tags: ${{ needs.checks.outputs.tags }} + architectures: '["amd64"]' username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push to DockerHub - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-nginx' - run: docker push kooldev/nginx:${{ matrix.version }} diff --git a/README.md b/README.md index 581f96c..4aadd82 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ CI builds all three variants for **linux/amd64**. ARM is not supported by the bundled dockerize binary. Weekly Monday rebuilds pull the latest `nginx:alpine` and refresh Alpine packages without reusing build layers. +CI uses [shared Bash/`jq` actions](https://github.com/kool-dev/action/blob/master/image-ci.md), +pinned in the workflow. Builds, HTTP tests and Grype scans stay here. After all +three jobs pass, one publisher promotes the tested/scanned digests as amd64-only +indexes. See the shared release rules for publication guards and retry behavior. + Run the same configuration and HTTP checks locally after building an image: ```sh