Skip to content

cleanup GitHub action releases #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/_gcp-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: GCP Deploy

on:
workflow_call:
inputs:
environment:
required: true
description: 'The environment to deploy to'
type: string

jobs:
gcp-deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
env:
IMAGE_PATH: us-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/sourcebot/sourcebot-${{ vars.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'
with:
submodules: "true"

# @see: https://github.com/google-github-actions/auth?tab=readme-ov-file#direct-wif
- name: 'Google auth'
id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
project_id: '${{ secrets.GCP_PROJECT_ID }}'
workload_identity_provider: '${{ secrets.GCP_WIF_PROVIDER }}'

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
with:
project_id: '${{ secrets.GCP_PROJECT_ID }}'

- name: 'Docker auth'
run: |-
gcloud auth configure-docker us-west1-docker.pkg.dev

- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.GCP_SSH_PRIVATE_KEY }}" > ~/.ssh/private.key
chmod 600 ~/.ssh/private.key
echo "${{ secrets.GCP_SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts

- name: Build Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.IMAGE_PATH }}:${{ github.sha }}
${{ env.IMAGE_PATH }}:latest
build-args: |
NEXT_PUBLIC_SOURCEBOT_VERSION=${{ github.ref_name }}
NEXT_PUBLIC_POSTHOG_PAPIK=${{ vars.NEXT_PUBLIC_POSTHOG_PAPIK }}
NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT=${{ vars.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT }}
NEXT_PUBLIC_SENTRY_ENVIRONMENT=${{ vars.NEXT_PUBLIC_SENTRY_ENVIRONMENT }}
NEXT_PUBLIC_SENTRY_WEBAPP_DSN=${{ vars.NEXT_PUBLIC_SENTRY_WEBAPP_DSN }}
NEXT_PUBLIC_SENTRY_BACKEND_DSN=${{ vars.NEXT_PUBLIC_SENTRY_BACKEND_DSN }}
SENTRY_SMUAT=${{ secrets.SENTRY_SMUAT }}
SENTRY_ORG=${{ vars.SENTRY_ORG }}
SENTRY_WEBAPP_PROJECT=${{ vars.SENTRY_WEBAPP_PROJECT }}
SENTRY_BACKEND_PROJECT=${{ vars.SENTRY_BACKEND_PROJECT }}


- name: Deploy to GCP
run: |
ssh -i ~/.ssh/private.key ${{ secrets.GCP_USERNAME }}@${{ secrets.GCP_HOST }} << 'EOF'
# First pull the new image
docker pull ${{ env.IMAGE_PATH }}:${{ github.sha }}

# Stop and remove any existing container
docker stop -t 60 sourcebot || true
docker rm sourcebot || true

# Run the new container
docker run -d \
-p 80:3000 \
--rm \
--env-file .env \
-v /mnt/data:/data \
--name sourcebot \
${{ env.IMAGE_PATH }}:${{ github.sha }}
EOF
18 changes: 18 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy Prod

on:
push:
tags: ["v*.*.*"]
workflow_dispatch:

jobs:
deploy-prod:
uses: ./.github/workflows/_gcp-deploy.yml
secrets: inherit
permissions:
contents: 'read'
# Requird for OIDC auth with GCP.
# @see: https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
id-token: 'write'
with:
environment: prod
20 changes: 20 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Deploy Staging

on:
push:
# @todo: remove v3 after merge is complete.
branches: [main, v3]
tags: ["v*.*.*"]
workflow_dispatch:

jobs:
deploy-staging:
uses: ./.github/workflows/_gcp-deploy.yml
secrets: inherit
permissions:
contents: 'read'
# Requird for OIDC auth with GCP.
# @see: https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
id-token: 'write'
with:
environment: staging
29 changes: 0 additions & 29 deletions .github/workflows/fly-deploy-staging.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/fly-deploy.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/gcp-deploy-staging.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/ghcr-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
jobs:
build:
runs-on: ${{ matrix.runs-on}}
environment: oss
permissions:
contents: read
packages: write
Expand All @@ -30,8 +31,6 @@ jobs:
- platform: linux/arm64
runs-on: ubuntu-24.04-arm



steps:
- name: Prepare
run: |
Expand Down Expand Up @@ -79,8 +78,8 @@ jobs:
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
build-args: |
SOURCEBOT_VERSION=${{ github.ref_name }}
POSTHOG_PAPIK=${{ secrets.POSTHOG_PAPIK }}
NEXT_PUBLIC_SOURCEBOT_VERSION=${{ github.ref_name }}
NEXT_PUBLIC_POSTHOG_PAPIK=${{ vars.NEXT_PUBLIC_POSTHOG_PAPIK }}

- name: Export digest
run: |
Expand Down
135 changes: 0 additions & 135 deletions .github/workflows/staging-ghcr-public.yml

This file was deleted.

Loading