-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calls validate workflow, commits new JSON files only if valid
- Loading branch information
1 parent
040182f
commit ee5ee6a
Showing
1 changed file
with
49 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,66 @@ on: | |
- "yaml/**.yaml" | ||
|
||
jobs: | ||
convert: | ||
convert-yaml: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run python script | ||
run: | | ||
python convert-yaml.py yaml json | ||
if [ -d "yaml" ] && [ "$(ls -A yaml/*.yaml 2>/dev/null)" ]; then | ||
python convert-yaml.py yaml json | ||
else | ||
echo "No YAML files to process." | ||
fi | ||
- name: Upload JSON artifacts for validation | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: json-files | ||
path: json/*.json | ||
|
||
validate-json: | ||
needs: convert-yaml | ||
uses: ./.github/workflows/validate.yml | ||
with: | ||
should_download: true | ||
|
||
commit-json: | ||
runs-on: ubuntu-latest | ||
needs: validate-json | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check for validation success and file changes | ||
run: | | ||
if [ "${{ needs.validate-json.outputs.is_valid }}" != "true" ]; then | ||
echo "JSON is not valid. Skipping commit." | ||
echo "NO_COMMIT=true" >> $GITHUB_ENV | ||
elif git diff --quiet; then | ||
echo "No changes to commit" | ||
echo "NO_COMMIT=true" >> $GITHUB_ENV | ||
fi | ||
- name: Commit changes | ||
if: ${{ env.NO_COMMIT != 'true' }} | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git add . | ||
git commit -m "Automated commit by GitHub Action" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |