-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (77 loc) · 3.16 KB
/
sitemap.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
75
76
77
78
79
name: Generate Sitemap
on:
push:
branches:
- "none"
pull_request:
branches:
- "none"
jobs:
create-release:
name: Generate Sitemap
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Check if the existing sitemap is up-to-date
id: requires_update
run: |
UPDATE_REQUIRED=`python3 ./.github/workflows/generate_sitemap.py -c`
echo "Check result: $UPDATE_REQUIRED"
echo "update_required=$UPDATE_REQUIRED" >> $GITHUB_OUTPUT
- name: Remove existing sitemaps
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
run: rm -f sitemap.xml
- name: Create sitemap
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
run: |
SITEMAP=`python3 ./.github/workflows/generate_sitemap.py`
echo "Generated sitemap:\n$SITEMAP"
echo "$SITEMAP" >> sitemap.xml
- name: Generate name for new branch
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
id: branch_name
run: |
COMMIT_HASH=`git rev-parse --short HEAD`
echo "Latest commit short hash: $COMMIT_HASH"
echo "branch_name=sitemaps/update-$COMMIT_HASH" >> $GITHUB_OUTPUT
- name: Generate commit message
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
id: commit_message
run: |
COMMIT_HASH=`git rev-parse --short HEAD`
echo "Latest commit short hash: $COMMIT_HASH"
echo "commit_message=update sitemap for commit $COMMIT_HASH" >> $GITHUB_OUTPUT
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
- name: Generate pull request body
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
id: request_body
run: |
DIFF=`git diff sitemap.xml`
echo "Generated diff of the sitemap:\n$DIFF"
echo "request_body<<EOF" >> $GITHUB_OUTPUT
echo "$DIFF" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create pull request
if: ${{ steps.requires_update.outputs.update_required == 'UPDATE-REQUIRED' }}
uses: peter-evans/create-pull-request@v5
with:
branch: ${{ steps.branch_name.outputs.branch_name }}
title: ${{ steps.commit_message.outputs.commit_message }}
body: |
Updates the sitemap.xml file for commit ${{ steps.commit_message.outputs.commit_hash }}.
```diff
${{ steps.request_body.outputs.request_body }}
```
_View the workflow run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}._
commit-message: ${{ steps.commit_message.outputs.commit_message }}
labels: |
sitemap update
delete-branch: true
signoff: true
author: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>