Merge pull request #51 from ivanildobarauna-dev/feature/ChangeDefault… #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: Build and Deploy to Cloud Run Job | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
- '*.md' | |
- '*.txt' | |
- 'LICENSE' | |
- .gitattributes | |
- .gitignore | |
workflow_dispatch: | |
env: | |
PROJECT_ID: pypi-package-analysis-437421 | |
GAR_LOCATION: us-east4 | |
REPO_NAME: pypi-package-analysis-ar | |
JOB_NAME: pypi-package-analysis-job | |
REGION: us-east4 | |
jobs: | |
deploy: | |
permissions: | |
contents: "read" | |
id-token: "write" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Google Auth | |
id: auth | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Configure Docker for Google Artifact Registry | |
run: | | |
gcloud auth configure-docker '${{ env.GAR_LOCATION }}-docker.pkg.dev' | |
- name: Build Container | |
run: |- | |
docker build -t ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/application-job:${{ github.sha }} ./ | |
- name: Push Container | |
run: docker push ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/application-job:${{ github.sha }} | |
- name: Deploy or Update Cloud Run Job | |
run: |- | |
gcloud run jobs update ${{ env.JOB_NAME }} \ | |
--image=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/application-job:${{ github.sha }} \ | |
--region=${{ env.REGION }} \ | |
--task-timeout=600s \ | |
--max-retries=3 | |
- name: Show Output | |
run: echo "Cloud Run Job ${{ env.JOB_NAME }} deployed/updated successfully in region ${{ env.REGION }}" | |
environment: | |
name: Production |