-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: move deploy jobs to separate release workflow
- Loading branch information
Showing
5 changed files
with
235 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Deploy | ||
description: Deploy to GCP | ||
inputs: | ||
project_id: | ||
description: "The GCP project ID" | ||
required: true | ||
identity_provider: | ||
description: "The identity provider for the workload identity" | ||
required: true | ||
service_account_email: | ||
description: "The service account email" | ||
required: true | ||
pause_schedule_job: | ||
description: "Pause the scheduler job" | ||
required: false | ||
default: "no" | ||
github_token: | ||
description: "The GitHub token" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: 🗝️ Authenticate to Google Cloud | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
workload_identity_provider: ${{ inputs.identity_provider }} | ||
service_account: ${{ inputs.service_account_email }} | ||
token_format: "access_token" | ||
|
||
- name: 🐳 Set up Docker Buildx | ||
id: builder | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: 🗝️ Authenticate Docker to Google Cloud | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: us-central1-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: ${{ steps.auth.outputs.access_token }} | ||
|
||
- name: 🏷️ Extract tags from GitHub | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
github-token: ${{ inputs.github_token }} | ||
images: us-central1-docker.pkg.dev/${{ inputs.project_id }}/images/job | ||
tags: | | ||
type=ref,suffix=-{{sha}},event=branch | ||
type=ref,prefix=pr-,suffix=-{{sha}},event=pr | ||
type=semver,pattern={{version}} | ||
latest | ||
- name: 📦 Build and push image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
builder: ${{ steps.builder.outputs.name }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
provenance: false | ||
|
||
- name: ☁️ Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v2 | ||
|
||
- name: 🚀 Deploy Cloud Run Job | ||
uses: google-github-actions/deploy-cloudrun@v2 | ||
with: | ||
project_id: ${{ inputs.project_id }} | ||
region: us-central1 | ||
image: us-central1-docker.pkg.dev/${{ inputs.project_id }}/images/job:latest | ||
job: default | ||
secrets: /secrets/app/secrets.json=skid-secrets:latest | ||
secrets_update_strategy: overwrite | ||
timeout: 3h | ||
flags: | | ||
--memory=3Gi | ||
--task-timeout=3h | ||
--max-retries=0 | ||
--service-account=cloud-run-sa@${{ inputs.project_id }}.iam.gserviceaccount.com | ||
- name: 🕰️ Create Cloud Scheduler | ||
shell: bash | ||
run: | | ||
for i in $(gcloud scheduler jobs list --location=us-central1 --uri); do | ||
gcloud scheduler jobs delete $i --quiet | ||
done | ||
gcloud scheduler jobs create http nfhl-schedule \ | ||
--description="Trigger the nfhl-skid bot once a week on saturday evening" \ | ||
--schedule="0 3 * * 1" \ | ||
--time-zone=America/Denver \ | ||
--location=us-central1 \ | ||
--uri="https://us-central1-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${{ inputs.project_id }}/jobs/default:run" \ | ||
--oauth-service-account-email=scheduler-sa@${{ inputs.project_id }}.iam.gserviceaccount.com | ||
- name: 🙅 Pause Scheduler Job | ||
shell: bash | ||
if: inputs.pause_schedule_job != 'no' | ||
run: | | ||
gcloud scheduler jobs pause "nfhl-schedule" --location=us-central1 --quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Pull Request Events | ||
|
||
on: pull_request | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: ⬇️ Set up code | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
cache: pip | ||
cache-dependency-path: setup.py | ||
|
||
- name: Install libkrb5 for Kerberos on Linux | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libkrb5-dev | ||
- name: Install module | ||
run: pip install .[tests] | ||
|
||
- name: 🧶 Lint | ||
run: ruff check --output-format=github . | ||
|
||
- name: 🧪 Run pytest | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.