Fix supply chain security vulnerabilities (picomatch, ldap3, maxminddb) #228
This file contains hidden or 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
| # Auth9 CD Pipeline | |
| # Builds and pushes Docker images on push to main | |
| # Images are pushed to ghcr.io/<repository_owner>/auth9-* | |
| name: CD | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAMESPACE: ${{ github.repository_owner }} | |
| CORE_IMAGE_NAME: auth9-core | |
| PORTAL_IMAGE_NAME: auth9-portal | |
| jobs: | |
| # ==================== Build and Push auth9-core ==================== | |
| build-core: | |
| name: Build auth9-core (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| runner: [self-hosted, linux, x64, arc-runner] | |
| - arch: arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: auth9-core/Dockerfile | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}:build-${{ github.sha }}-${{ matrix.arch }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/${{ matrix.arch }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| printf '%s\n' "${{ steps.build.outputs.digest }}" > "/tmp/digests/${{ matrix.arch }}.txt" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-auth9-core-${{ matrix.arch }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-core: | |
| name: Merge auth9-core manifest | |
| runs-on: ubuntu-latest | |
| needs: build-core | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: digests-auth9-core-* | |
| path: /tmp/digests/auth9-core | |
| merge-multiple: true | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }} | |
| tags: | | |
| type=sha,prefix= | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch | |
| - name: Create manifest list | |
| working-directory: /tmp/digests/auth9-core | |
| run: | | |
| TAG_ARGS="" | |
| while IFS= read -r tag; do | |
| [ -n "$tag" ] && TAG_ARGS="$TAG_ARGS -t $tag" | |
| done <<< "${{ steps.meta.outputs.tags }}" | |
| SOURCES="" | |
| for digest_file in *; do | |
| digest=$(tr -d '\n' < "$digest_file") | |
| SOURCES="$SOURCES ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}@${digest}" | |
| done | |
| docker buildx imagetools create $TAG_ARGS $SOURCES | |
| # ==================== Build and Push auth9-portal ==================== | |
| build-portal: | |
| name: Build auth9-portal (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| runner: [self-hosted, linux, x64, arc-runner] | |
| - arch: arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: auth9-portal/Dockerfile | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}:build-${{ github.sha }}-${{ matrix.arch }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/${{ matrix.arch }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| printf '%s\n' "${{ steps.build.outputs.digest }}" > "/tmp/digests/${{ matrix.arch }}.txt" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-auth9-portal-${{ matrix.arch }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-portal: | |
| name: Merge auth9-portal manifest | |
| runs-on: ubuntu-latest | |
| needs: build-portal | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: digests-auth9-portal-* | |
| path: /tmp/digests/auth9-portal | |
| merge-multiple: true | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }} | |
| tags: | | |
| type=sha,prefix= | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch | |
| - name: Create manifest list | |
| working-directory: /tmp/digests/auth9-portal | |
| run: | | |
| TAG_ARGS="" | |
| while IFS= read -r tag; do | |
| [ -n "$tag" ] && TAG_ARGS="$TAG_ARGS -t $tag" | |
| done <<< "${{ steps.meta.outputs.tags }}" | |
| SOURCES="" | |
| for digest_file in *; do | |
| digest=$(tr -d '\n' < "$digest_file") | |
| SOURCES="$SOURCES ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}@${digest}" | |
| done | |
| docker buildx imagetools create $TAG_ARGS $SOURCES | |
| # ==================== Generate Summary ==================== | |
| summary: | |
| name: Deployment Summary | |
| runs-on: ubuntu-latest | |
| needs: [merge-core, merge-portal] | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Generate deployment summary | |
| run: | | |
| SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| cat >> $GITHUB_STEP_SUMMARY << 'EOF' | |
| ## 🚀 Docker Images Built Successfully | |
| Commit: `${{ github.sha }}` | |
| Branch: `${{ github.ref_name }}` | |
| ### auth9-core | |
| ``` | |
| ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}:${SHORT_SHA} | |
| ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}:latest | |
| ``` | |
| ### auth9-portal | |
| ``` | |
| ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}:${SHORT_SHA} | |
| ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}:latest | |
| ``` | |
| ### Quick Copy (with commit SHA) | |
| | Component | Image | | |
| |-----------|-------| | |
| | auth9-core | `ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}:${SHORT_SHA}` | | |
| | auth9-portal | `ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}:${SHORT_SHA}` | | |
| ### Quick Copy (latest) | |
| | Component | Image | | |
| |-----------|-------| | |
| | auth9-core | `ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.CORE_IMAGE_NAME }}:latest` | | |
| | auth9-portal | `ghcr.io/${{ env.IMAGE_NAMESPACE }}/${{ env.PORTAL_IMAGE_NAME }}:latest` | | |
| ### Architectures | |
| These images are published as multi-arch manifests for: | |
| - `linux/amd64` | |
| - `linux/arm64` | |
| --- | |
| To deploy, run: | |
| ```bash | |
| ./deploy/deploy.sh | |
| ``` | |
| EOF | |
| # Substitute variables in the summary | |
| sed -i "s/\${SHORT_SHA}/${SHORT_SHA}/g" $GITHUB_STEP_SUMMARY |