Skip to content

gh actions: update gh actions #489

gh actions: update gh actions

gh actions: update gh actions #489

Workflow file for this run

name: Remove preview
permissions:
issues: write
pull-requests: write
contents: write
on:
pull_request:
types:
- closed
jobs:
remove:
name: "Remove preview build"
runs-on: ubuntu-20.04
concurrency:
group: ovirt-site-preview-build
cancel-in-progress: false
steps:
- name: Checkout gh-actions branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Extract PR details
id: details
run: |
PR_ID=${{ github.event.pull_request.number }}
PREVIEW_PATH=previews/${PR_ID}
PREVIEW_LINK=https://$(echo "${{github.repository}}" | sed -e 's#/#.github.io/#')/${PREVIEW_PATH}
PREVIEW_LINK_PATH="$(echo $PREVIEW_LINK | sed -e 's#.*\.io/#/#')"
PREVIEW_LINK_BASE="$(echo $PREVIEW_LINK | sed -e 's#\.io.*#.io#')"
echo "PR_ID=${PR_ID}" >> $GITHUB_OUTPUT
echo "PREVIEW_PATH=${PREVIEW_PATH}" >> $GITHUB_OUTPUT
echo "PREVIEW_LINK=${PREVIEW_LINK}" >> $GITHUB_OUTPUT
echo "PREVIEW_LINK_PATH=${PREVIEW_LINK_PATH}" >> $GITHUB_OUTPUT
echo "PREVIEW_LINK_BASE=${PREVIEW_LINK_BASE}" >> $GITHUB_OUTPUT
- name: Comment on PR
continue-on-error: true
run: |
set -euo pipefail
echo "Hey there, we noticed that this PR is now closed, so we'll remove the preview build now." >/tmp/comment
gh pr comment ${{steps.details.outputs.PR_ID}} -F /tmp/comment
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Remove branch preview
run: rm -rf ${{steps.details.outputs.PREVIEW_PATH}}
- name: Commit changes
run: |
set -euo pipefail
git config user.name "GitHub Actions"
git config user.email [email protected]
git add .
if ! git diff-index --quiet HEAD --; then
git commit -m "Removing preview build for PR ${{steps.details.outputs.PR_ID}}"
git push --set-upstream origin gh-pages
else
echo -e "No changes found."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}