added github checkout #11
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 app | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
checks: 'write' | |
env: | |
PROJECT_ID: profound-coyote-418718 | |
jobs: | |
# <------------------ DEPLOY APP to GCP -------------------> | |
deploy-app: | |
name: Deploy app | |
runs-on: self-hosted | |
outputs: | |
env_url: ${{ steps.deploy.outputs.url }} | |
environment: | |
name: ${{ needs.build-image.outputs.branch }} | |
url: ${{ steps.deploy.outputs.url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Slugify github variables | |
uses: rlespinasse/github-slug-action@v4 | |
- name: Authenticate to GCP (SA Key) | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.APPLICATION_SA }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Deploy to Cloud function | |
id: deploy | |
run: |- | |
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}" --quiet | |
folder_name=temp_src_function_${{ env.GITHUB_SHA_SHORT }} | |
mkdir $folder_name && cp main.py requirements.txt $folder_name/ | |
gcloud functions deploy my-python-app-1 \ | |
--region=europe-west1 \ | |
--runtime=python312 \ | |
--source=$folder_name \ | |
--service-account [email protected] \ | |
--memory=256MB \ | |
--timeout=300 \ | |
--trigger-http \ | |
--entry-point=hello_http | |
--allow-unauthenticated | |