Clean Up AWS Resources #215
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 AWS Resources | |
on: | |
schedule: | |
- cron: '5 9 * * *' # every day at 9:05 am UTC | |
jobs: | |
test-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Restore cached Nix store | |
id: nix-cache-restore | |
uses: john-shaffer/cache/restore@main | |
with: | |
key: nix-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('**.nix', '**/flake.lock') }} | |
restore-keys: | | |
nix-${{ github.repository }}-${{ runner.os }}- | |
path: | | |
/nix/store | |
/nix/var/nix/db/db.sqlite | |
- name: Install Nix | |
uses: cachix/install-nix-action@v22 | |
- name: Build Nix derivations | |
if: steps.nix-cache-restore.outputs.cache-hit != 'true' | |
run: | | |
nix develop -c echo OK | |
- name: Save cached Nix store | |
if: steps.nix-cache-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
key: nix-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('**.nix', '**/flake.lock') }} | |
path: | | |
/nix/store | |
/nix/var/nix/db/db.sqlite | |
- name: Restore cached Clojure dependencies | |
id: clj-cache-restore | |
uses: actions/cache/restore@v3 | |
with: | |
key: clj-${{ github.repository }}-${{ hashFiles('**/deps.edn') }} | |
restore-keys: clj-${{ github.repository }}- | |
path: | | |
~/.gitlibs | |
~/.m2/repository | |
- name: Pull Clojure dependencies | |
if: steps.clj-cache-restore.outputs.cache-hit != 'true' | |
run: | | |
nix develop -c clojure -P | |
nix develop -c clojure -A:build -P | |
nix develop -c clojure -A:test -P | |
- name: Save cached Clojure dependencies | |
if: steps.clj-cache-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
key: clj-${{ github.repository }}-${{ hashFiles('**/deps.edn') }} | |
path: | | |
~/.gitlibs | |
~/.m2/repository | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-region: us-east-1 | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
mask-aws-account-id: no | |
- name: Run cleanup | |
# Make sure that no one forks this and accidentally | |
# deletes all their stuff. | |
if: ${{ github.repository }} == 'john-shaffer/salmon' | |
run: nix develop -c clj -X salmon.cleanup/delete-all! :confirm? true |