Destroy environment (CRON) #23
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: Destroy environment (CRON) | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "33 20 * * *" # Every day at 20:33 | |
jobs: | |
destroy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Unlabel open PRs with deploy label | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/search/issues?q=is:open+is:pr+label:deploy+repo:betagouv/service-national-universel" | jq -r '.items[].labels_url' | sed 's#{/name}#/deploy#g' > prs.txt | |
cat prs.txt | xargs -n 1 curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.17" | |
- name: Destroy environment | |
env: | |
SCW_SECRET_KEY: ${{ secrets.SCW_CI_DEPLOY_SECRET_KEY }} | |
SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }} | |
run: node devops/scripts/destroy-all-environments.js --apply-changes |