Skip to content

Delete preview from OVH Object Storage #1597

Delete preview from OVH Object Storage

Delete preview from OVH Object Storage #1597

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._