Github actions: hardcode artifact registry path #18
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
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 | |
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 | |
id: gcp-auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' # GCP service account JSON key | |
token_format: 'access_token' | |
# Step 3: Set up Google Cloud SDK | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
#with: | |
# version: 'latest' | |
# project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Docker Auth | |
id: docker-auth | |
uses: 'docker/login-action@v1' | |
with: | |
username: 'oauth2accesstoken' | |
password: '${{ steps.gcp-auth.outputs.access_token }}' | |
registry: '${{ secrets.GCP_REGION }}-docker.pkg.dev' | |
# 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 }}/streamlit-app/streamlit-app:$GITHUB_SHA . | |
# Step 6: Push Docker image to Google Artifact Registry | |
- name: Push Docker image to Artifact Registry | |
run: | | |
# gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://${{ secrets.GCP_REGION }}-docker.pkg.dev | |
docker push us-central1-docker.pkg.dev/streamlit-app-434012/streamlit-app:$GITHUB_SHA | |
#docker push ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/streamlit-app/streamlit-app:$GITHUB_SHA | |
# Step 7: Deploy to Cloud Run using the Artifact Registry image | |
#- name: Deploy to Cloud Run | |
# run: | | |
# gcloud run deploy streamlit-app \ | |
# --image ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_PROJECT_REPO }}/streamlit-app:$GITHUB_SHA \ | |
# --platform managed \ | |
# --region ${{ secrets.GCP_REGION }} \ | |
# --allow-unauthenticated |