11name : cleanup PR
22
3- on :
4- pull_request_target :
5- types : [closed]
3+ # on:
4+ # pull_request_target:
5+ # types: [closed]
6+
7+ on : [pull_request_target]
68
79permissions : {}
810
@@ -14,11 +16,13 @@ jobs:
1416 clean-artifacts :
1517 if : always()
1618 runs-on : ubuntu-latest
17- continue-on-error : true
19+ permissions :
20+ actions : write
21+
1822 steps :
1923 - name : Clean artifacts
2024 run : |
21- set -eu
25+ set -u
2226
2327 ARTIFACTS=$(
2428 gh api \
@@ -41,28 +45,33 @@ jobs:
4145 --silent \
4246 -H "Accept: application/vnd.github+json" \
4347 -H "X-GitHub-Api-Version: 2022-11-28" \
44- /repos/${OWNER }/${REPOSITORY }/actions/artifacts/${ID}
48+ /repos/${REPOSITORY_OWNER }/${REPOSITORY_NAME }/actions/artifacts/${ID}
4549 done
4650 env :
4751 GH_TOKEN : ${{ github.token }}
48- OWNER : ${{ github.repository_owner }}
49- REPOSITORY : ${{ github.repository.name }}
52+ REPOSITORY_OWNER : ${{ github.repository_owner }}
53+ REPOSITORY_NAME : ${{ github.event .repository.name }}
5054 BRANCH : ${{ github.head_ref }}
5155
5256 clean-documentation-preview :
5357 if : always()
5458 runs-on : ubuntu-latest
55- continue-on-error : true
5659 steps :
57- - name : Clean documentation preview
60+ - name : Install `rclone`
61+ shell : bash
5862 run : |
59- set -eu
6063 sudo apt-get update
6164 sudo apt-get install -y rclone
62- echo "${{ inputs.CONFIGURATION }}" > rclone.configuration
63- rclone --config rclone.configuration prune ${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}/
65+
66+ - name : Copy configuration
67+ shell : bash
68+ run : echo "${CONFIGURATION}" > rclone.configuration
6469 env :
6570 CONFIGURATION : ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}
71+
72+ - name : Clean documentation preview
73+ run : rclone --config rclone.configuration purge "${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}" -vvvv
74+ env :
6675 PROVIDER : scaleway
6776 BUCKET : ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}
68- PULL_REQUEST_NUMBER : ${{ github.event.number }}
77+ PULL_REQUEST_NUMBER : 1027 # ${{ github.event.number }}
0 commit comments