Created
          April 1, 2021 14:47 
        
      - 
      
- 
        Save theguuholi/2e525f21774823c9a61f9cdf989a5883 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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
    
  
  
    
  | on: | |
| push: | |
| branches: | |
| - main | |
| name: Build and Deploy a Container | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT }} | |
| SERVICE: rushing | |
| REGION: us-central1 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Setup Cloud SDK | |
| uses: google-github-actions/[email protected] | |
| with: | |
| project_id: ${{ env.PROJECT_ID }} | |
| service_account_key: ${{ secrets.GCP_SA_KEY }} | |
| export_default_credentials: true | |
| - name: Authorize Docker push | |
| run: gcloud auth configure-docker | |
| - name: Build and Push Container | |
| run: |- | |
| docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} . | |
| docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} | |
| - name: Deploy to Cloud Run | |
| id: deploy | |
| uses: google-github-actions/[email protected] | |
| with: | |
| service: ${{ env.SERVICE }} | |
| image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} | |
| region: ${{ env.REGION }} | |
| - name: Show Output | |
| run: echo ${{ steps.deploy.outputs.url }} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment