Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions .github/workflows/commit_to_main.yml

This file was deleted.

36 changes: 6 additions & 30 deletions .github/workflows/pull_request_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,9 @@ jobs:

test-rendering:
name: Test rendering xml file to markdown and yaml
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
python -m pip install --upgrade pip
python -m pip install PyYaml

- name: Test rendering xml file to markdown
run: |
tools/write_standard_name_table.py --output-format md standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.md

- name: Test rendering xml file to yaml
run: |
tools/write_standard_name_table.py --output-format yaml standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.yaml
needs: [check-unique-standard-names, check-name-rules]
uses: ./.github/workflows/render.yml
with:
commit_to_branch: false
branch_name: "invalid_branch_name"
remote_url: "invalid_remote_url"
23 changes: 23 additions & 0 deletions .github/workflows/pull_request_precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pull request precommit tasks

on:
# This workflow is only valid for pull_request events
#workflow_dispatch:
pull_request:
branches:
- main
- release/*
types: [labeled]

jobs:

render-and-commit:
name: Rendering xml file to markdown and yaml, and commit to branch
if: ${{ github.event.label.name == 'render-and-commit' }}
uses: ./.github/workflows/render.yml
with:
commit_to_branch: true
# github.head_ref is the branch from which a pull request is made
branch_name: ${{ github.head_ref }}
# github.event.pull_request.head.repo.clone_url is the URL from where the pull request is made
remote_url: ${{ github.event.pull_request.head.repo.clone_url }}
68 changes: 68 additions & 0 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Render XML to output formats and optionally commit to branch

on:
workflow_call:
inputs:
commit_to_branch:
required: true
type: boolean
branch_name:
required: true
type: string
remote_url:
required: true
type: string

jobs:

render_to_markdown_and_yaml:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
python -m pip install --upgrade pip
python -m pip install PyYaml

- name: Render xml file to markdown
run: |
tools/write_standard_name_table.py --output-format md standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.md

- name: Rendering xml file to yaml
run: |
tools/write_standard_name_table.py --output-format yaml standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.yaml

- name: Configure git, commit and push changes
if: ${{ inputs.commit_to_branch }}
run: |
set -u
echo "Submitting rendered standard name dictionaries to branch ${BRANCH_NAME} in ${REMOTE_URL}"
set +u
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin ${REMOTE_URL}
git checkout -b ${BRANCH_NAME}
git add .
git commit -m "Update Metadata-standard-names.{md,yaml} from standard_names.xml" || echo "No changes to commit"
git remote -v show
git status
git push origin ${BRANCH_NAME}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ inputs.branch_name }}
REMOTE_URL: ${{ inputs.remote_url }}
Loading