|
| 1 | +name: Production CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v* |
| 7 | + |
| 8 | +env: |
| 9 | + BASE_IMAGE: ghcr.io/graphprotocol/graph-docs-production |
| 10 | + HEALTH_CHECK_URL: https://thegraph.com/docs |
| 11 | + APP_NAME: graph-docs |
| 12 | + NEXT_PUBLIC_BASE_PATH: /docs |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout the repo |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Login to GitHub Container Registry |
| 22 | + uses: docker/login-action@v1 |
| 23 | + with: |
| 24 | + registry: ghcr.io |
| 25 | + username: Jannis |
| 26 | + password: ${{ secrets.GH_ACCESS_TOKEN_JANNIS }} |
| 27 | + |
| 28 | + - name: Build and push Docker image |
| 29 | + uses: docker/build-push-action@v2 |
| 30 | + with: |
| 31 | + context: . # required to respect .dockerignore |
| 32 | + cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest |
| 33 | + cache-to: type=inline |
| 34 | + secrets: npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_SECRET_TOKEN }} |
| 35 | + tags: | |
| 36 | + ${{ env.BASE_IMAGE }}:${{ github.sha }} |
| 37 | + ${{ env.BASE_IMAGE }}:latest |
| 38 | + push: true |
| 39 | + build-args: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} |
| 40 | + |
| 41 | + deploy: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + needs: build |
| 44 | + steps: |
| 45 | + - name: Checkout the repo |
| 46 | + uses: actions/checkout@v2 |
| 47 | + |
| 48 | + - name: Set up kubectl |
| 49 | + uses: google-github-actions/get-gke-credentials@main |
| 50 | + with: |
| 51 | + cluster_name: hosted-service |
| 52 | + location: us-central1-a |
| 53 | + credentials: ${{ secrets.GCP_SA_KEY_PRODUCTION }} |
| 54 | + |
| 55 | + - name: Set a new k8s image and apply the manifests |
| 56 | + run: .github/scripts/kustomize-apply.sh production $APP_NAME=$BASE_IMAGE:$GITHUB_SHA |
| 57 | + |
| 58 | + - name: Wait for pods to be ready |
| 59 | + run: .github/scripts/kubectl-wait-ready.sh $APP_NAME |
| 60 | + |
| 61 | + - name: Check the endpoints |
| 62 | + run: .github/scripts/npx-wait-on/run.sh $HEALTH_CHECK_URL |
0 commit comments