feat(config): Add workflow for the automatic config conversion #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatic conversion of application.yml to ors-config.yml | |
on: | |
pull_request: | |
branches: | |
- main | |
- releases/** | |
- feat/config-cleanup-finalize # for testing | |
types: [ edited, opened, ready_for_review, review_requested, reopened, closed, synchronize ] | |
workflow_dispatch: | |
jobs: | |
detect_config_change: | |
name: Detect and commit config changes | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Check PR state is ready_for_review | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
pr_is_open=$(gh pr view --json state --jq .state) | |
pr_is_draft=$(gh pr view --json isDraft --jq .isDraft) | |
if [ "$pr_is_open" != "OPEN" ] || [ "$pr_is_draft" == "true" ]; then | |
echo "Please make sure the PR is open and ready for review. The check will not succeed otherwise." | |
exit 1 | |
fi | |
else | |
echo "This action is only intended to be run on pull requests." | |
exit 1 | |
fi | |
- name: Convert application.yml to ors-config.yml | |
run: | | |
.github/utils/config_conversion.sh ors-api/src/main/resources/application.yml ors-api/ors-config.yml | |
- name: Check with git if ors-api/ors-config.yml has changed | |
id: git-check | |
run: | | |
# Don't fail on exit code 1 (diff found) | |
set +e | |
git diff --exit-code --name-only ors-api/ors-config.yml | |
exit_value=$? | |
echo Found exit code $exit_value | |
# Write out the exit code using environment file | |
if [ $exit_value == 1 ]; then | |
echo "config_has_changed=true" >> $GITHUB_ENV | |
fi | |
- uses: MichaelsJP/git-auto-commit-action@v5 | |
if: env.config_has_changed == 'true' | |
with: | |
commit_message: 'chore(config): automatic conversion of application.yml to ors-config.yml' |