|
| 1 | +name: Activate ad-network jobs runtime |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + release_sha: |
| 6 | + description: Exact deployed main commit to package (unused when pausing) |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + confirm: |
| 10 | + description: Type stack127-production to authorize activation and automatic production data writes |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + enabled_jobs: |
| 14 | + description: Comma-separated jobs; empty stops the existing jobs service without website or Storage checks |
| 15 | + required: false |
| 16 | + default: snapshot,platform,domain-age,ads-txt-summary,discovery,publisher-names,traffic,backup,verification,rdap-import |
| 17 | + type: string |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | +concurrency: |
| 22 | + group: stack127-production |
| 23 | + cancel-in-progress: false |
| 24 | + queue: max |
| 25 | +jobs: |
| 26 | + pause: |
| 27 | + if: inputs.enabled_jobs == '' |
| 28 | + environment: production |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 15 |
| 31 | + env: |
| 32 | + CONFIRM: ${{ inputs.confirm }} |
| 33 | + DOKPLOY_API_URL: ${{ vars.STACK127_DOKPLOY_API_URL }} |
| 34 | + DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }} |
| 35 | + CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }} |
| 36 | + CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }} |
| 37 | + steps: |
| 38 | + - name: Require explicit confirmation |
| 39 | + run: | |
| 40 | + test "$GITHUB_REF" = refs/heads/main |
| 41 | + test "$CONFIRM" = stack127-production |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - uses: actions/setup-node@v4 |
| 44 | + with: |
| 45 | + node-version: 22 |
| 46 | + cache: npm |
| 47 | + - run: npm ci --omit=dev --ignore-scripts |
| 48 | + - name: Verify service identity, stop containers and persist paused admissions |
| 49 | + run: node --experimental-strip-types scripts/ad-networks/deploy-runtime.mjs pause |
| 50 | + activate: |
| 51 | + if: inputs.enabled_jobs != '' |
| 52 | + environment: production |
| 53 | + runs-on: ubuntu-latest |
| 54 | + timeout-minutes: 75 |
| 55 | + env: |
| 56 | + AD_NETWORKS_RUNTIME_ENVIRONMENT: production |
| 57 | + CONFIRM: ${{ inputs.confirm }} |
| 58 | + RELEASE_SHA: ${{ inputs.release_sha }} |
| 59 | + DEPLOYMENT_ID: ${{ github.run_id }}-${{ github.run_attempt }} |
| 60 | + ENABLED_JOBS: ${{ inputs.enabled_jobs }} |
| 61 | + DOKPLOY_API_URL: ${{ vars.STACK127_DOKPLOY_API_URL }} |
| 62 | + DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }} |
| 63 | + CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }} |
| 64 | + CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }} |
| 65 | + DATABASE_POOLER_URL: ${{ secrets.DATABASE_POOLER_URL }} |
| 66 | + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} |
| 67 | + SUPABASE_SECRET_KEY: ${{ secrets.SUPABASE_SECRET_KEY }} |
| 68 | + GITHUB_ALERT_TOKEN: ${{ secrets.AD_NETWORKS_ALERT_TOKEN }} |
| 69 | + GHCR_DOKPLOY_USERNAME: ${{ vars.GHCR_DOKPLOY_USERNAME }} |
| 70 | + GHCR_DOKPLOY_TOKEN: ${{ secrets.GHCR_DOKPLOY_TOKEN }} |
| 71 | + steps: |
| 72 | + - name: Require explicit confirmation |
| 73 | + run: | |
| 74 | + test "$GITHUB_REF" = refs/heads/main |
| 75 | + test "$CONFIRM" = stack127-production |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + ref: ${{ inputs.release_sha }} |
| 79 | + fetch-depth: 0 |
| 80 | + - name: Check released main commit |
| 81 | + run: | |
| 82 | + [[ "$RELEASE_SHA" =~ ^[a-f0-9]{40}$ ]] |
| 83 | + test "$(git rev-parse HEAD)" = "$RELEASE_SHA" |
| 84 | + test "$(git rev-parse origin/main)" = "$RELEASE_SHA" |
| 85 | + - uses: actions/setup-node@v4 |
| 86 | + with: |
| 87 | + node-version: 22 |
| 88 | + cache: npm |
| 89 | + - run: npm ci --omit=dev --ignore-scripts |
| 90 | + - name: Read-only capacity, seed and publication preflight |
| 91 | + run: node --experimental-strip-types scripts/ad-networks/deploy-runtime.mjs preflight |
| 92 | + - uses: docker/setup-buildx-action@v3 |
| 93 | + - uses: docker/login-action@v3 |
| 94 | + with: |
| 95 | + registry: ghcr.io |
| 96 | + username: ${{ github.actor }} |
| 97 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + - name: Build the jobs image locally on the GitHub runner |
| 99 | + uses: docker/build-push-action@v6 |
| 100 | + with: |
| 101 | + context: . |
| 102 | + file: scripts/ad-networks/runtime/Dockerfile |
| 103 | + load: true |
| 104 | + push: false |
| 105 | + tags: ghcr.io/stack127labs/stack127-ad-networks:${{ inputs.release_sha }} |
| 106 | + labels: | |
| 107 | + org.opencontainers.image.revision=${{ inputs.release_sha }} |
| 108 | + org.opencontainers.image.source=https://github.com/stack127labs/stack127 |
| 109 | + cache-from: type=gha,scope=ad-networks-runtime |
| 110 | + cache-to: type=gha,mode=max,scope=ad-networks-runtime |
| 111 | + - name: Smoke required executables and scheduler health before pushing |
| 112 | + run: | |
| 113 | + docker run --rm --network none --read-only --tmpfs /tmp:rw,size=128m,mode=1777 \ |
| 114 | + --entrypoint node "ghcr.io/stack127labs/stack127-ad-networks:$RELEASE_SHA" \ |
| 115 | + --experimental-strip-types scripts/ad-networks/runtime/smoke.mjs |
| 116 | + - name: Push the tested jobs image |
| 117 | + run: docker push "ghcr.io/stack127labs/stack127-ad-networks:$RELEASE_SHA" |
| 118 | + - name: Recheck admission, create or update Compose, deploy and wait healthy |
| 119 | + run: node --experimental-strip-types scripts/ad-networks/deploy-runtime.mjs activate |
0 commit comments