-
Notifications
You must be signed in to change notification settings - Fork 2
33 lines (32 loc) · 1.15 KB
/
cleanup-artifacts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: 'CI-cleanup-artifacts'
on:
workflow_run:
types:
- completed
workflows: [CI-pr, CI-push]
jobs:
on-success:
runs-on: ubuntu-latest
name: Cleanup artifact
steps:
- name: Login
run: |
export GH_CONFIG_DIR=$PWD/.config
echo "GH_CONFIG_DIR=$GH_CONFIG_DIR" >> $GITHUB_ENV
mkdir $GH_CONFIG_DIR
echo "${{ secrets.KIIROTORI_GH_CONFIG_HOSTS }}" > $GH_CONFIG_DIR/hosts.yml
echo "${{ secrets.KIIROTORI_GH_CONFIG_CONFIG }}" > $GH_CONFIG_DIR/config.yml
- name: Get ID
run: |
echo "ARTIFACT_ID=$(gh api -H 'Accept: application/vnd.github+json' ${{ github.event.workflow_run.artifacts_url }} --jq .artifacts[].id)" >> $GITHUB_ENV
- name: Cleanup
if: env.ARTIFACT_ID != ''
run: |
gh api --method DELETE -H 'Accept: application/vnd.github+json' ${{ env.ENDPOINT }}
env:
ENDPOINT: /repos/${{ github.repository }}/actions/artifacts/${{ env.ARTIFACT_ID }}
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'