Delete Application #317
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: "Delete Application" | |
on: | |
schedule: | |
- cron: '10 22 * * 1-5' | |
workflow_dispatch: | |
jobs: | |
Delete: | |
env: | |
gcp_project: "project1-366201" | |
region: "us-central1" | |
application_name: "embedded-my-tomcat-app" | |
PCC_API: ${{ secrets.PCC_API }} | |
PCC_KEY: ${{ secrets.PCC_KEY }} | |
PCC_SEC: ${{ secrets.PCC_SEC }} | |
service_account : "sample-google-cloud-run@project1-366201.iam.gserviceaccount.com" | |
workload_identity_provider: "projects/917516087101/locations/global/workloadIdentityPools/sample-google-cloud-run/providers/sample-google-cloud-run-provider" | |
# Add "id-token" with the intended permissions. | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Content from Repo | |
uses: actions/checkout@v3 # checkout the repository content | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # install the python version needed | |
- name: install python packages for | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r policy/requirements.txt | |
- name: Generate Compute Login Token | |
run: python policy/create-token.py | |
- name: Delete Compute App-Embedded Runtime Policy for Application | |
run: python policy/delete-policy.py | |
continue-on-error: true | |
- name: Delete Compute Collection for Application | |
run: python policy/delete-collection.py | |
continue-on-error: true | |
- name: Authenticate to Google Cloud for Deployment | |
id: 'gcp-auth' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
workload_identity_provider: '${{env.workload_identity_provider}}' | |
service_account: '${{env.service_account}}' | |
- name: Delete application on Google-Cloud-Run | |
run: gcloud run services delete ${{env.application_name}} --region ${{env.region}} --quiet | |
continue-on-error: true | |
- name: Delete Application from Google Artifact Repository | |
run: gcloud artifacts repositories delete ${{env.application_name}} --location ${{env.region}} --quiet | |
continue-on-error: true |