Skip to content

🚀release-docs-gcp #11

🚀release-docs-gcp

🚀release-docs-gcp #11

name: 🚀release-docs-gcp
on:
workflow_dispatch:
inputs:
permissions:
id-token: write
contents: read
env:
DOGU_AWS_REGION: ap-northeast-2
DOCS_GA_ID: G-5WLY043T9W
DOGU_GCP_REGION: asia-northeast3
DOGU_GCP_PROJECT_ID: ${{secrets.GCP_PROD_PROJECT_ID}}
DOGU_DOCS_GAR_LOCATION: asia-northeast3-docker.pkg.dev/${{secrets.GCP_PROD_PROJECT_ID}}/dogu-docs-test
jobs:
build:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Yarn Unplugged
uses: actions/cache@v3
id: cache_yarn_unplugged
env:
cache-name: cache-yarn-unplugged
with:
path: ${{ github.workspace }}/.yarn/unplugged
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Write env for production
run: echo "GOOGLE_ANALYTICS_ID=$GOOGLE_ANALYTICS_ID" >> ./docs/.env
env:
GOOGLE_ANALYTICS_ID: ${{ env.DOCS_GA_ID }}
- name: Build docs
run: yarn build
- id: auth
name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v1"
with:
token_format: 'access_token'
credentials_json: "${{ secrets.GCP_PROD_CICD_SA_KEY }}"
access_token_lifetime: '300s'
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
- name: Login to Artifact Registry
uses: docker/login-action@v2
with:
registry: ${{env.DOGU_GCP_REGION}}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Push to Artifact Registry
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{env.DOGU_DOCS_GAR_LOCATION}}/dogu-docs-test:latest
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCP_PROD_CICD_SA_KEY }}"
- id: 'compute-ssh'
uses: 'google-github-actions/ssh-compute@v0'
with:
instance_name: 'dogu-docs'
zone: ${{env.DOGU_GCP_REGION}}-a
ssh_private_key: '${{ secrets.GCP_PROD_PRIVATE_SSH_KEY }}'
command: |
gcloud auth configure-docker asia-northeast3-docker.pkg.dev --quiet && \
docker ps -qa | xargs -r docker rm -f && \
docker system prune --volumes -a -f && \
docker pull ${{env.DOGU_DOCS_GAR_LOCATION}}/dogu-docs-test:latest && \
docker run -d -p 3100:3100 ${{env.DOGU_DOCS_GAR_LOCATION}}/dogu-docs-test:latest && \
docker image prune -a -f
crawl-docs:
runs-on: ubuntu-latest
needs: release
steps:
- name: Algolia recrawl
uses: algolia/[email protected]
id: algolia_crawler
with:
crawler-user-id: ${{ secrets.DOCS_CRAWLER_USER_ID }}
crawler-api-key: ${{ secrets.DOCS_CRAWLER_API_KEY }}
algolia-app-id: ${{ secrets.DOCS_ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.DOCS_ALGOLIA_API_KEY }}
site-url: 'https://docs.dogutech.io'
crawler-name: 'dogutech'
send-slack:
runs-on: ubuntu-latest
needs: crawl-docs
if: ${{ always() }}
steps:
- name: Send Slack
uses: dogu-team/[email protected]
with:
template: 'CD'
slack-channel-id: 'C057ML9UH34'
result-status: ${{ needs.crawl-docs.result }}
ignore-notify: false
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}