Skip to content

Commit 0b4ff91

Browse files
committed
Test render+commit based on label
1 parent 422cfb5 commit 0b4ff91

File tree

4 files changed

+141
-30
lines changed

4 files changed

+141
-30
lines changed

.github/workflows/pull_request_ci.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,37 @@ jobs:
5353
5454
test-rendering:
5555
name: Test rendering xml file to markdown and yaml
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Checkout repository
59-
uses: actions/checkout@v4
60-
61-
- name: Setup Python
62-
uses: actions/setup-python@v4
63-
with:
64-
python-version: "3.x"
65-
66-
- name: Install dependencies
67-
run: |
68-
sudo apt-get update
69-
sudo apt-get -y install libxml2-utils
70-
python -m pip install --upgrade pip
71-
python -m pip install PyYaml
72-
73-
- name: Test rendering xml file to markdown
74-
run: |
75-
tools/write_standard_name_table.py --output-format md standard_names.xml
76-
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
77-
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
78-
git diff Metadata-standard-names.md
79-
80-
- name: Test rendering xml file to yaml
81-
run: |
82-
tools/write_standard_name_table.py --output-format yaml standard_names.xml
83-
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
84-
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
85-
git diff Metadata-standard-names.yaml
56+
needs: [check-unique-standard-names, check-name-rules]
57+
uses: ./.github/workflows/render.yml
58+
with:
59+
commit_to_branch: false
60+
#runs-on: ubuntu-latest
61+
#steps:
62+
# - name: Checkout repository
63+
# uses: actions/checkout@v4
64+
#
65+
# - name: Setup Python
66+
# uses: actions/setup-python@v4
67+
# with:
68+
# python-version: "3.x"
69+
#
70+
# - name: Install dependencies
71+
# run: |
72+
# sudo apt-get update
73+
# sudo apt-get -y install libxml2-utils
74+
# python -m pip install --upgrade pip
75+
# python -m pip install PyYaml
76+
#
77+
# - name: Test rendering xml file to markdown
78+
# run: |
79+
# tools/write_standard_name_table.py --output-format md standard_names.xml
80+
# echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
81+
# echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
82+
# git diff Metadata-standard-names.md
83+
#
84+
# - name: Test rendering xml file to yaml
85+
# run: |
86+
# tools/write_standard_name_table.py --output-format yaml standard_names.xml
87+
# echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
88+
# echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
89+
# git diff Metadata-standard-names.yaml
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Pull request precommit tasks
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
- release/*
9+
types: [labeled]
10+
11+
jobs:
12+
13+
render-and-commit:
14+
name: Rendering xml file to markdown and yaml, and commit to branch
15+
if: ${{ github.event.label.name == 'render-and-commit' }}
16+
uses: ./.github/workflows/render.yml
17+
with:
18+
commit_to_branch: true
19+
#runs-on: ubuntu-latest
20+
#steps:
21+
# - name: Checkout repository
22+
# uses: actions/checkout@v4
23+
#
24+
# - name: Setup Python
25+
# uses: actions/setup-python@v4
26+
# with:
27+
# python-version: "3.x"
28+
#
29+
# - name: Install dependencies
30+
# run: |
31+
# sudo apt-get update
32+
# sudo apt-get -y install libxml2-utils
33+
# python -m pip install --upgrade pip
34+
# python -m pip install PyYaml
35+
#
36+
# - name: Test rendering xml file to markdown
37+
# run: |
38+
# tools/write_standard_name_table.py --output-format md standard_names.xml
39+
# echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
40+
# echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
41+
# git diff Metadata-standard-names.md
42+
#
43+
# - name: Test rendering xml file to yaml
44+
# run: |
45+
# tools/write_standard_name_table.py --output-format yaml standard_names.xml
46+
# echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
47+
# echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
48+
# git diff Metadata-standard-names.yaml

.github/workflows/render.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Render XML to output formats and optionally commit to branch
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
commit_to_branch:
7+
required: true
8+
type: string
9+
10+
#env:
11+
# #COMMIT_TO_BRANCH: ${{ inputs.commit_to_branch }}
12+
13+
jobs:
14+
15+
render_to_markdown_and_yaml:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.x"
25+
26+
- name: Install dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get -y install libxml2-utils
30+
python -m pip install --upgrade pip
31+
python -m pip install PyYaml
32+
33+
- name: Render xml file to markdown
34+
run: |
35+
tools/write_standard_name_table.py --output-format md standard_names.xml
36+
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
37+
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
38+
git diff Metadata-standard-names.md
39+
40+
- name: Rendering xml file to yaml
41+
run: |
42+
tools/write_standard_name_table.py --output-format yaml standard_names.xml
43+
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
44+
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
45+
git diff Metadata-standard-names.yaml
46+
47+
- name: Configure git
48+
if: ${{ inputs.commit_to_branch }}
49+
run: |
50+
git config --global user.name "github-actions[bot]"
51+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
52+
53+
- name: Commit and push changes
54+
if: ${{ inputs.commit_to_branch }}
55+
run: |
56+
git commit -m "Update Metadata-standard-names.{md,yaml} from standard_names.xml" || echo "No changes to commit"
57+
git push
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)