-
Notifications
You must be signed in to change notification settings - Fork 5
43 lines (39 loc) · 1.57 KB
/
documentation-preview-cleanup.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
34
35
36
37
38
39
40
41
42
43
name: Documentation Preview Cleanup
on:
workflow_run:
workflows: [Documentation Preview Cleanup Request]
types:
- completed
env:
PREVIEW_PUBLISH_USERNAME: crc-org
PREVIEW_PUBLISH_REPOSITORY: crc-docs-gh-action-generated-preview
PREVIEW_PUBLISH_BRANCH: gh-pages
PREVIEW_PUBLISH_TOKEN: ${{ secrets.PREVIEW_PUBLISH_TOKEN }}
jobs:
on-close:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-24.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: cleanup-info
path: .
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Extract Pull Request ID from artifact
run: |
echo "PR_NUMBER=$(jq '.event.pull_request.number' github_context.json)" >> $GITHUB_ENV
rm github_context.json
- name: Push updates to external repository
run: |
git clone https://${PREVIEW_PUBLISH_USERNAME}:${PREVIEW_PUBLISH_TOKEN}@github.com/${PREVIEW_PUBLISH_USERNAME}/${PREVIEW_PUBLISH_REPOSITORY}.git -b ${PREVIEW_PUBLISH_BRANCH}
cd ${PREVIEW_PUBLISH_REPOSITORY}
rm -rf preview/pr/${PR_NUMBER}
git add preview/pr/${PR_NUMBER}
git commit -am "cleanup (preview) : remove preview for Pull Request #${PR_NUMBER}"
git push origin ${PREVIEW_PUBLISH_BRANCH}