🧹 Clean stale build artifacts #77
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 stale build artifacts | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * SUN" | |
jobs: | |
clean: | |
name: Clean | |
runs-on: ubuntu-22.04 | |
container: | |
image: nycplanning/dev:latest | |
defaults: | |
run: | |
shell: bash | |
env: | |
GHP_TOKEN: ${{ github.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load Secrets | |
uses: 1password/load-secrets-action@v1 | |
with: | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
BUILD_ENGINE_SERVER: "op://Data Engineering/EDM_DATA/server_url" | |
DOCKER_USERNAME: "op://Data Engineering/Dockerhub/username" | |
DOCKER_PASSWORD: "op://Data Engineering/Dockerhub/password" | |
- name: Delete build artifacts | |
run: python3 -m dcpy.lifecycle.builds.clean_artifacts schemas | |
- name: Delete docker images | |
run: python3 -m dcpy.lifecycle.builds.clean_artifacts dockerhub_tags | |
create_issue_on_failure: | |
needs: clean | |
runs-on: ubuntu-22.04 | |
if: ${{ failure() && (github.event_name == 'schedule') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: .github | |
- name: Create issue on failure | |
uses: JasonEtco/create-an-issue@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ACTION: ${{ github.workflow }} | |
BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
with: | |
filename: .github/ISSUE_TEMPLATE/scheduled_action_failure.md |