Clean up playground happy stacks #83
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: Clean up playground happy stacks | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
schedule: | |
# Runs "every Friday at midnight" (see https://crontab.guru) | |
- cron: '0 0 * * 5' | |
workflow_dispatch: {} | |
jobs: | |
find-examples: | |
name: Find examples | |
runs-on: [ARM64, self-hosted, Linux] | |
outputs: | |
examples: ${{ steps.findExamples.outputs.examples }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/github-script@v6 | |
id: findExamples | |
with: | |
script: | | |
const fs = require("fs") | |
const examples = fs.readdirSync("examples") | |
console.log(`Found the following examples dirs: ${JSON.stringify(examples, null, 2)}`) | |
core.setOutput("examples", examples) | |
clean-rdev: | |
needs: find-examples | |
strategy: | |
matrix: | |
example: ${{ fromJson(needs.find-examples.outputs.examples) }} | |
if: ${{ needs.find-examples.outputs.examples != '[]' }} | |
defaults: | |
run: | |
working-directory: ./examples/${{matrix.example}} | |
name: Clean rdev happy stacks | |
runs-on: [ARM64, self-hosted, Linux] | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: us-west-2 | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2 | |
role-duration-seconds: 1800 | |
role-session-name: HappyCleanupPlaygroundStacks | |
- name: Clean up stale happy stacks | |
uses: chanzuckerberg/github-actions/.github/actions/[email protected] | |
with: | |
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}} | |
time: 1 minutes | |
clean-staging: | |
needs: find-examples | |
strategy: | |
matrix: | |
example: ${{ fromJson(needs.find-examples.outputs.examples) }} | |
if: ${{ needs.find-examples.outputs.examples != '[]' }} | |
defaults: | |
run: | |
working-directory: ./examples/${{matrix.example}} | |
name: Clean staging happy stacks | |
runs-on: [ARM64, self-hosted, Linux] | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: us-west-2 | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2 | |
role-duration-seconds: 1800 | |
role-session-name: HappyCleanupPlaygroundStacks | |
- name: Clean up stale happy stacks | |
uses: chanzuckerberg/github-actions/.github/actions/[email protected] | |
with: | |
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}} | |
time: 1 minutes | |
clean-prod: | |
needs: find-examples | |
strategy: | |
matrix: | |
example: ${{ fromJson(needs.find-examples.outputs.examples) }} | |
if: ${{ needs.find-examples.outputs.examples != '[]' }} | |
defaults: | |
run: | |
working-directory: ./examples/${{matrix.example}} | |
name: Clean prod happy stacks | |
runs-on: [ARM64, self-hosted, Linux] | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: us-west-2 | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2 | |
role-duration-seconds: 1800 | |
role-session-name: HappyCleanupPlaygroundStacks | |
- name: Clean up stale happy stacks | |
uses: chanzuckerberg/github-actions/.github/actions/[email protected] | |
with: | |
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}} | |
time: 1 minutes |