Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is a basic workflow to help you get started with Actions
- name: CD
- # Controls when the workflow will run
- on:
- # Triggers the workflow on push or pull request events but only for the main branch
- push:
- branches: [main]
- pull_request:
- branches: [main]
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
- # A workflow run is made up of one or more jobs that can run sequentially or in parallel
- jobs:
- # This workflow contains a single job called "deploy"
- deploy:
- # The type of runner that the job will run on
- runs-on: ubuntu-latest
- # Add "id-token" with the intended permissions.
- permissions:
- contents: "read"
- id-token: "write"
- env:
- IMAGE_NAME: us-central1-docker.pkg.dev/my-project/test/my-image
- # Steps represent a sequence of tasks that will be executed as part of the job
- steps:
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - name: Checkout repository
- uses: actions/checkout@v2
- - name: Authenticate to Google Cloud
- uses: google-github-actions/auth@v0
- with:
- workload_identity_provider: "projects/1115519312/locations/global/workloadIdentityPools/gh-pool/providers/gh-provider"
- service_account: "github-actions-service-account@my-project.iam.gserviceaccount.com"
- - name: Configure Docker
- run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- - name: Build Docker with cache layer
- uses: whoan/docker-build-with-cache-action@v5
- with:
- # username: _json_key
- # password: "${{ secrets.GCLOUD_JSON_KEY }}"
- registry: us-central1-docker.pkg.dev
- image_name: "my-project/test/my-image"
- push_image_and_stages: false
- # image_tag: "latest"
- # - name: Build Docker image
- # run: docker build . -t us-central1-docker.pkg.dev/my-project/test/my-image:latest
- - name: Push Docker image
- run: docker push us-central1-docker.pkg.dev/my-project/test/my-image:latest
- - id: deploy
- name: Deploy Docker image
- uses: "google-github-actions/deploy-cloudrun@v0"
- with:
- image: us-central1-docker.pkg.dev/my-project/test/my-image:latest
- region: us-central1
- service: app
- flags: --port=8080
- # Example of using the output
- - name: Test URL
- run: curl "${{ steps.deploy.outputs.url }}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement