terminal sin #8
Workflow file for this run
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: 'Build and Deploy to Cloud Run' | |
on: | |
push: | |
branches: | |
- testdeployhell | |
jobs: | |
test-vars: | |
environment: GCR | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
REGION: ${{ secrets.GCP_REGION }} | |
SERVICE: ${{ secrets.GCP_SERVICE_NAME }} | |
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
TEST: ${{ vars.TEST}} | |
name: Test Var | |
runs-on: ubuntu-latest | |
steps: | |
- name: region test | |
run: echo "the region is ${{ env.REGION }}" | |
- name: Test Service | |
run: echo "Service is ${{ env.SERVICE }}" | |
- name: Test WORKLOAD_IDENTITY_PROVIDER | |
run: echo "WORKLOAD_IDENTITY_PROVIDER is ${{ env.WORKLOAD_IDENTITY_PROVIDER }}" | |
- name: Test PROJECT_ID | |
run: echo "PROJECT_ID is ${{ env.PROJECT_ID }}" | |
- name: Test ENV version | |
run: echo "HELP ME is ${{env.test}}" | |
deploy: | |
runs-on: 'ubuntu-latest' | |
environment: GCR | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
REGION: ${{ secrets.GCP_REGION }} | |
SERVICE: ${{ secrets.GCP_SERVICE_NAME }} | |
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: 'Checkout' | |
uses: 'actions/checkout@v4' | |
# Configure Workload Identity Federation and generate an access token. | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | |
# Docker authentication and build | |
- name: 'Docker Auth' | |
uses: 'docker/login-action@v3' | |
with: | |
username: 'oauth2accesstoken' | |
password: '${{ steps.auth.outputs.auth_token }}' | |
registry: '${{ env.REGION }}-docker.pkg.dev' | |
- name: 'Build and Push Container' | |
run: |- | |
DOCKER_TAG="australia-southeast1-docker.pkg.dev/flaskimageconverter/flaskconverter:${{ github.sha }}" | |
docker build --tag "${DOCKER_TAG}" . | |
docker push "${DOCKER_TAG}" | |
- name: 'Deploy to Cloud Run' | |
uses: 'google-github-actions/deploy-cloudrun@v2' | |
with: | |
service: ${{ env.SERVICE }} | |
region: ${{ env.REGION }} | |
image: '${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}' | |
- name: 'Show output' | |
run: |- | |
echo ${{ steps.deploy.outputs.url }} |