Sadhbh a/gcp guide - WIP #31066
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Post preview link | |
on: | |
pull_request: | |
paths: | |
- 'content/en/**.md' | |
permissions: | |
contents: read | |
pull-requests: write | |
# Stop the current running job if a new push is made to the PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
preview-link: | |
if: contains(github.head_ref, '/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: '3.10' | |
- run: pip install Mako docutils | |
- name: Find changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v42 | |
with: | |
include_all_old_new_renamed_files: true | |
- name: Generate links | |
env: | |
branch: ${{ github.head_ref }} | |
DELETED_FILES: ${{ steps.changed_files.outputs.deleted_files }} | |
RENAMED_FILES: ${{ steps.changed_files.outputs.renamed_files }} | |
MODIFIED_FILES: ${{ steps.changed_files.outputs.modified_files }} | |
ADDED_FILES: ${{ steps.changed_files.outputs.added_files }} | |
id: comment_body | |
run: | | |
python local/bin/py/preview_links.py --deleted="${DELETED_FILES}" \ | |
--renamed="${RENAMED_FILES}" \ | |
--modified="${MODIFIED_FILES}" \ | |
--added="${ADDED_FILES}" | |
- name: Render template | |
id: template | |
uses: chuhlomin/[email protected] | |
with: | |
template: .github/preview-links-template.md | |
- name: Find existing comment | |
uses: peter-evans/[email protected] | |
id: find_comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: "Preview links (" | |
- name: Post comment | |
uses: peter-evans/[email protected] | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
edit-mode: replace | |
body: ${{ steps.template.outputs.result }} |