diff --git a/.github/scripts/deploy-registry.sh b/.github/scripts/deploy-registry.sh new file mode 100644 index 0000000..22c0c4c --- /dev/null +++ b/.github/scripts/deploy-registry.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -o pipefail +set -u + +VERBOSE="${VERBOSE:-0}" +if [[ "${VERBOSE}" -ne "0" ]]; then + set -x +fi + +# List of required environment variables +required_vars=( + "GCLOUD_API_KEY" + "GCLOUD_PROD_DEPLOY_SECRET" + "GCLOUD_DEV_DEPLOY_SECRET" +) + +# Check if each required variable is set +for var in "${required_vars[@]}"; do + if [[ -z "${!var:-}" ]]; then + echo "Error: Environment variable '$var' is not set." + exit 1 + fi +done + +# Trigger a build for dev +curl -X POST "https://cloudbuild.googleapis.com/v1/projects/coder-registry-1/triggers/http-build-registry-v2-dev:webhook?key=${GCLOUD_API_KEY}&secret=${GCLOUD_DEV_DEPLOY_SECRET}" \ +-H "Content-Type: application/json" \ +-d '{}' + +# Trigger a build for prod +curl -X POST "https://cloudbuild.googleapis.com/v1/projects/coder-registry-1/triggers/http-build-registry-v2-trigger:webhook?key=${GCLOUD_API_KEY}&secret=${GCLOUD_PROD_DEPLOY_SECRET}" \ +-H "Content-Type: application/json" \ +-d '{}' \ No newline at end of file diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 02422ff..d2e788b 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -15,7 +15,7 @@ jobs: - name: Run check.sh run: | - ./.github/scripts/check.sh + ./.github/scripts/deploy-registry.sh env: INSTATUS_API_KEY: ${{ secrets.INSTATUS_API_KEY }} INSTATUS_PAGE_ID: ${{ secrets.INSTATUS_PAGE_ID }} diff --git a/.github/workflows/deploy-registry.yaml b/.github/workflows/deploy-registry.yaml new file mode 100644 index 0000000..ea45391 --- /dev/null +++ b/.github/workflows/deploy-registry.yaml @@ -0,0 +1,25 @@ +name: deploy-registry + +on: + push: + branches: + - main + + pull_request: + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Run check.sh + run: | + ./.github/scripts/check.sh + env: + GCLOUD_API_KEY: ${{ secrets.GCLOUD_API_KEY }} + GCLOUD_PROD_DEPLOY_SECRET: ${{ secrets.GCLOUD_PROD_DEPLOY_SECRET }} + GCLOUD_DEV_DEPLOY_SECRET: ${{ secrets.GCLOUD_DEV_DEPLOY_SECRET }} + \ No newline at end of file