Skip to content

Commit

Permalink
refactor: update workflow names and paths for cloudrun deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 4, 2024
1 parent 511f69e commit d557327
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/deploy_api.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Deploy API to cloud-run
name: Deploy api to cloudrun
on:
pull_request:
paths:
- "api/**"
- "services/**"
- "utils_pkg/**"
- ".github/workflows/api.yml"
- ".github/workflows/deploy_api.yml"
push:
branches:
- main
paths:
- "api/**"
- "services/**"
- "utils_pkg/**"
- ".github/workflows/api.yml"
- ".github/workflows/deploy_api.yml"
tags:
- "release-*"

Expand Down Expand Up @@ -55,6 +55,8 @@ jobs:
runs-on: ubuntu-latest
needs: [prepare]
timeout-minutes: 10
permissions:
pull-requests: write
env:
VERSION: ${{ needs.prepare.outputs.VERSION }}
steps:
Expand Down Expand Up @@ -114,7 +116,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: [prepare, deploy]
timeout-minutes: 2
timeout-minutes: 3
steps:
- uses: google-github-actions/auth@v2
with:
Expand All @@ -125,12 +127,12 @@ jobs:
cleanup:
runs-on: ubuntu-latest
needs: promote
timeout-minutes: 2
timeout-minutes: 3
steps:
- uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GCP_SA_KEY }}"
- uses: google-github-actions/setup-gcloud@v2
- name: Cleanup older revisions
- name: cleanup older revisions
run: |
gcloud run revisions list --service=${{ env.SERVICE }} --project=${{ env.PROJECT_ID }} --region=us-central1 --sort-by=CREATE_TIME --format="value(REVISION)" | tail -n +4 | xargs -I {} gcloud run revisions delete {} --project=${{ env.PROJECT_ID }} --region=us-central1 --quiet
19 changes: 12 additions & 7 deletions .github/workflows/deploy_app.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Deploy app to Google Cloudrun
name: Deploy app to cloudrun
on:
pull_request:
paths:
- "app/**"
- "services/**"
- "utils_pkg/**"
- ".streamlit"
- ".github/workflows/deploy_app.yml"
push:
branches:
Expand All @@ -14,7 +13,6 @@ on:
- "app/**"
- "services/**"
- "utils_pkg/**"
- ".streamlit"
- ".github/workflows/deploy_app.yml"
tags:
- "release-*"
Expand All @@ -36,6 +34,7 @@ jobs:
prepare:
runs-on: ubuntu-latest
outputs:
SHORT_SHA: ${{ steps.prepare_env.outputs.SHORT_SHA }}
VERSION: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('main-{0}', steps.prepare_env.outputs.SHORT_SHA) }}
steps:
- uses: actions/checkout@v4
Expand All @@ -44,18 +43,24 @@ jobs:
- id: prepare_env
run: |
echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/api') }}" >> $GITHUB_OUTPUT
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
SHORT_SHA=$(git rev-parse --short HEAD)
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
RAW=$(git branch -r --contains $SHORT_SHA)
TAG_BRANCH_NAME="${RAW##*/}"
echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
needs: [prepare]
timeout-minutes: 10
permissions:
pull-requests: write
env:
VERSION: ${{ needs.prepare.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand Down Expand Up @@ -83,7 +88,7 @@ jobs:
with:
service: ${{ env.SERVICE }}
source: ./
tag: ${{ needs.prepare.outputs.VERSION }}
tag: ${{ env.VERSION }}
no_traffic: true
timeout: "5m"
gcloud_version: "482.0.0"
Expand Down

0 comments on commit d557327

Please sign in to comment.