-
Notifications
You must be signed in to change notification settings - Fork 57
74 lines (65 loc) · 2.52 KB
/
delete-preview.yaml
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Delete preview from OVH Object Storage
on:
workflow_run:
workflows: ["Ask preview removal for a given PR"]
types:
- completed
jobs:
upload:
name: Upload preview to OVH Object Storage
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "PR"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/PR.zip', Buffer.from(download.data));
- run: unzip PR.zip
- name: Get PR number
id: pr_number
run: echo "pr_number=$(cat PR_NUMBER)" >> $GITHUB_OUTPUT
- name: Install Swift
run: |
pip install python-swiftclient==4.3.0 python-keystoneclient==5.1.0
- name: OVH Object Storage
run: |
swift delete sekoiaio-documentation-previews -p ${{ steps.pr_number.outputs.pr_number }} --object-threads 5
env:
OS_AUTH_URL: "https://auth.cloud.ovh.net/v3/"
OS_IDENTITY_API_VERSION: 3
OS_TENANT_ID: ${{ secrets.PR_OS_TENANT_ID }}
OS_TENANT_NAME: ${{ secrets.PR_OS_TENANT_NAME }}
OS_USERNAME: ${{ secrets.PR_OS_USERNAME }}
OS_PASSWORD: ${{ secrets.PR_OS_PASSWORD }}
OS_REGION_NAME: "GRA"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ steps.pr_number.outputs.pr_number }}
comment-author: github-actions[bot]
body-includes: Newest code from ${{ github.actor}} has been published to
- name: Add comment to PR
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ steps.pr_number.outputs.pr_number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
_Pull request was merged, preview was removed._