Skip to content

Commit a50a0fe

Browse files
committed
Fix render.yml: configure branch name, use correct boolean type for inputs
1 parent 0b4ff91 commit a50a0fe

File tree

3 files changed

+61
-60
lines changed

3 files changed

+61
-60
lines changed

.github/workflows/pull_request_ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
uses: ./.github/workflows/render.yml
5858
with:
5959
commit_to_branch: false
60+
branch_name: ${{ github.event_name == "pull_request" && github.head_ref || github.ref_name }}
6061
#runs-on: ubuntu-latest
6162
#steps:
6263
# - name: Checkout repository

.github/workflows/pull_request_precommit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Pull request precommit tasks
22

33
on:
4-
workflow_dispatch:
4+
#workflow_dispatch:
55
pull_request:
66
branches:
77
- main
@@ -16,6 +16,8 @@ jobs:
1616
uses: ./.github/workflows/render.yml
1717
with:
1818
commit_to_branch: true
19+
branch_name: ${{ github.head_ref }} # ${{ github.event_name == "pull_request" && github.head_ref || github.ref_name }}
20+
1921
#runs-on: ubuntu-latest
2022
#steps:
2123
# - name: Checkout repository

.github/workflows/render.yml

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
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 }}
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: boolean
9+
branch_name:
10+
required: true
11+
type: string
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, commit and push changes
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+
git checkout -b ${{ inputs.branch_name }}
53+
git commit -m "Update Metadata-standard-names.{md,yaml} from standard_names.xml" || echo "No changes to commit"
54+
git push
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
#BRANCH_NAME: ${{ github.event_name == "pull_request" && github.head_ref || github.ref_name }}

0 commit comments

Comments
 (0)