Advertisement
Itailulu

GH GC issue

Sep 29th, 2022
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.50 KB | None | 0 0
  1. # This is a basic workflow to help you get started with Actions
  2. name: CD
  3.  
  4. # Controls when the workflow will run
  5. on:
  6.  # Triggers the workflow on push or pull request events but only for the main branch
  7.   push:
  8.     branches: [main]
  9.   pull_request:
  10.     branches: [main]
  11.  
  12.   # Allows you to run this workflow manually from the Actions tab
  13.   workflow_dispatch:
  14. # A workflow run is made up of one or more jobs that can run sequentially or in parallel
  15. jobs:
  16.  # This workflow contains a single job called "deploy"
  17.   deploy:
  18.    # The type of runner that the job will run on
  19.     runs-on: ubuntu-latest
  20.  
  21.     # Add "id-token" with the intended permissions.
  22.     permissions:
  23.       contents: "read"
  24.       id-token: "write"
  25.  
  26.     env:
  27.       IMAGE_NAME: us-central1-docker.pkg.dev/my-project/test/my-image
  28.  
  29.     # Steps represent a sequence of tasks that will be executed as part of the job
  30.     steps:
  31.      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  32.       - name: Checkout repository
  33.         uses: actions/checkout@v2
  34.  
  35.       - name: Authenticate to Google Cloud
  36.         uses: google-github-actions/auth@v0
  37.         with:
  38.           workload_identity_provider: "projects/1115519312/locations/global/workloadIdentityPools/gh-pool/providers/gh-provider"
  39.           service_account: "github-actions-service-account@my-project.iam.gserviceaccount.com"
  40.  
  41.       - name: Configure Docker
  42.         run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
  43.  
  44.       - name: Build Docker with cache layer
  45.         uses: whoan/docker-build-with-cache-action@v5
  46.         with:
  47.          # username: _json_key
  48.           # password: "${{ secrets.GCLOUD_JSON_KEY }}"
  49.           registry: us-central1-docker.pkg.dev
  50.           image_name: "my-project/test/my-image"
  51.           push_image_and_stages: false
  52.           # image_tag: "latest"
  53.  
  54.       # - name: Build Docker image
  55.       #   run: docker build . -t us-central1-docker.pkg.dev/my-project/test/my-image:latest
  56.  
  57.       - name: Push Docker image
  58.         run: docker push us-central1-docker.pkg.dev/my-project/test/my-image:latest
  59.  
  60.       - id: deploy
  61.         name: Deploy Docker image
  62.         uses: "google-github-actions/deploy-cloudrun@v0"
  63.         with:
  64.           image: us-central1-docker.pkg.dev/my-project/test/my-image:latest
  65.           region: us-central1
  66.           service: app
  67.           flags: --port=8080
  68.  
  69.       # Example of using the output
  70.       - name: Test URL
  71.         run: curl "${{ steps.deploy.outputs.url }}"
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement