Update Syntax Files #752
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
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
name: Update Syntax Files | |
on: | |
schedule: | |
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows | |
- cron: '0 19 */2 * *' # every second day at 7 p.m. | |
workflow_dispatch: | |
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ | |
defaults: | |
run: | |
shell: bash | |
env: | |
JAVA_VERSION: 17 | |
jobs: | |
########################################################### | |
update-syntax-files: | |
########################################################### | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show environment variables | |
run: env | sort | |
- name: Git Checkout | |
uses: actions/checkout@v4 # https://github.com/actions/checkout | |
- name: "Install: JDK ${{ env.JAVA_VERSION }}" | |
uses: actions/setup-java@v4 # https://github.com/actions/setup-java | |
with: | |
distribution: temurin | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: "Install: Maven" | |
uses: stCarolas/setup-maven@v5 # https://github.com/stCarolas/setup-maven | |
with: | |
maven-version: 3.9.6 | |
- name: Update Syntax Files | |
id: update_syntaxes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -euo pipefail | |
# workaround for https://github.com/qjebbs/vscode-plantuml | |
sudo git config --system core.symlinks false | |
bash plugin/updater/run.sh | |
updates=$(git status --porcelain plugin/syntaxes | { grep -v LICENSE.txt || test $? = 1; }) | |
if [[ -z $updates ]]; then | |
echo "updates=" >> "$GITHUB_OUTPUT" | |
else | |
# https://github.com/orgs/community/discussions/26288#discussioncomment-3876281 | |
delimiter="$(openssl rand -hex 8)" | |
echo "updates<<${delimiter}" >> "${GITHUB_OUTPUT}" | |
echo "${updates}" >> "${GITHUB_OUTPUT}" | |
echo "${delimiter}" >> "${GITHUB_OUTPUT}" | |
fi | |
- name: Create PR | |
id: create-pr | |
uses: peter-evans/create-pull-request@v6 # https://github.com/peter-evans/create-pull-request | |
if: "${{ steps.update_syntaxes.outputs.updates != '' }}" | |
with: | |
title: "chore: Update Syntax Files" | |
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | |
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | |
commit-message: "chore: Update Syntax Files" | |
body: ${{ steps.update_syntaxes.outputs.updates }} | |
add-paths: | | |
plugin/updater/updater-state.yaml | |
plugin/syntaxes | |
plugin/plugin.xml | |
README.md | |
branch: dependencies/syntaxes | |
delete-branch: true | |
token: ${{ secrets.GH_TOKEN }} |