-
Notifications
You must be signed in to change notification settings - Fork 4
55 lines (45 loc) · 1.85 KB
/
deploy-streamlit-app.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Deploy Streamlit App to Cloud Run
on:
push:
branches:
- master # Triggers the action on push to the master branch
workflow_dispatch: # Allows manual triggering of the workflow from GitHub Actions
env:
REPOSITORY: streamlit-app-repo
IMAGE: streamlit-app
jobs:
deploy:
name: Deploy Streamlit to Cloud Run using Artifact Registry
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Authenticate GCP
- name: Authenticate GCP
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}' # GCP service account JSON key
# Step 3: Set up Google Cloud SDK
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
# Step 4: Configure Docker to use Artifact Registry
- name: Authenticate Docker to Artifact Registry
run: |
gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev
# Step 5: Build Docker Image for Streamlit app
- name: Build Docker image
run: |
docker build -t ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/$REPOSITORY/$IMAGE:$GITHUB_SHA .
# Step 6: Push Docker image to Google Artifact Registry
- name: Push Docker image to Artifact Registry
run: |
docker push ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/$REPOSITORY/$IMAGE:$GITHUB_SHA
# Step 7: Deploy to Cloud Run using the Artifact Registry image
- name: Deploy to Cloud Run
run: |
gcloud run deploy streamlit-app-testing \
--image ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/$REPOSITORY/$IMAGE:$GITHUB_SHA \
--platform managed \
--region ${{ secrets.GCP_REGION }} \
--allow-unauthenticated