|
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