Skip to content

Commit

Permalink
Merge branch 'master' into themes/58
Browse files Browse the repository at this point in the history
  • Loading branch information
romw314 authored Dec 8, 2023
2 parents 34c7aa3 + c913572 commit 353e906
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 51 deletions.
78 changes: 28 additions & 50 deletions .github/workflows/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,80 +59,58 @@ jobs:
- name: Report error
if: ${{ steps.extractcmd.outputs.err == 'true' }}
run: |
gh pr comment ${{ github.event.issue.number }} --body ':x: Could not find the update data. Type `!help update-theme` to get help.'
gh pr comment ${{ github.event.issue.number }} --body ' Could not find the update data. Type `!help update-theme` to get help.'
exit 1
env:
GH_TOKEN: ${{ github.token }}
- name: Make the change
id: change
run: |
echo "CHANGE_LOGS<<EOF" >> "$GITHUB_ENV"
node scripts/add-new-theme.cjs "$(jq <<< "$THEMEINFO" ".$PROP=$GOOD")" >> "$GITHUB_ENV"
echo '==============================' >> "$GITHUB_ENV"
cat themes.new.json | jq --tab . | tee src/themes.json >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
node scripts/add-new-theme.cjs "$(jq <<< "$THEMEINFO" ".$PROP=$GOOD")"
echo '=============================='
cat themes.new.json | jq --tab . | tee src/themes.json
env:
THEMEINFO: ${{ steps.parse.outputs.parsed-issue }}
PROP: ${{ steps.extractcmd.outputs.prop }}
GOOD: ${{ steps.extractcmd.outputs.good }}
- name: Configure Git
id: gitconfig
run: |
echo "GIT_CONFIG_LOGS<<EOF" >> "$GITHUB_ENV"
git config --global user.name "$GNAME" && git config --global user.email "$GEMAIL" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
git config --global user.name "$GNAME"
git config --global user.email "$GEMAIL"
env:
GNAME: ${{ github.actor }}
GEMAIL: ${{ github.actor }}@users.noreply.github.com
- name: Commit and push
id: commit
run: |
echo "COMMIT_LOGS<<EOF" >> "$GITHUB_ENV"
git add src/themes.json >> "$GITHUB_ENV"
git commit -m"Update $PROP to $GOOD" >> "$GITHUB_ENV"
git push >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
git add src/themes.json
git commit -m"Update $PROP to $GOOD"
git push
env:
PROP: ${{ steps.extractcmd.outputs.prop }}
GOOD: ${{ steps.extractcmd.outputs.good }}
- name: Report error
if: ${{ failure() }}
uses: actions/github-script@v7.0.1
with:
script: |
switch (['change', 'gitconfig', 'commit'].map(step => context.steps[step].conclusion).indexOf('failure')) {
case 1: // change
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:x: An error occured while doing the change:\n\n\`\`\`${context.env.CHANGE_LOGS}`
});
break;
case 2: // gitconfig
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:x: An internal error occured while configuring Git:\n\n\`\`\`${context.env.GIT_CONFIG_LOGS}\`\`\``
});
break;
case 3: // commit
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:x: An internal error occured while commiting the changes:\n\n\`\`\`${context.env.COMMIT_LOGS}\`\`\``
});
break;
default: // will usually be -1
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: An internal error occured.'
});
}
run: |
if [ "$CHANGE" = failure ]; then
gh issue comment ${{ github.event.issue.number }} --body '❌ An error occured while doing the change.'
elif [ "$GITCONFIG" = failure ]; then
gh issue comment ${{ github.event.issue.number }} --body '❌ An internal error occured while configuring Git.'
elif [ "$COMMIT" = failure ]; then
gh issue comment ${{ github.event.issue.number }} --body '❌ An internal error occured while commiting the changes.'
else
gh issue comment ${{ github.event.issue.number }} --body '❌ An internal error occured.'
fi
env:
CHANGE: ${{ steps.change.conclusion }}
CHLOGS: ${{ steps.change.logs }}
GITCONFIG: ${{ steps.gitconfig.conclusion }}
GCLOGS: ${{ steps.gitconfig.logs }}
COMMIT: ${{ steps.commit.conclusion }}
COMMIT_LOGS: ${{ steps.commit.logs }}
PROP: ${{ steps.extractcmd.outputs.prop }}
GH_TOKEN: ${{ github.token }}
- name: Comment on PR
run: |
gh pr comment ${{ github.event.issue.number }} --body "🎉 Updated \`$PROP\` successfully 👏"
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-creating-your-custom-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Choose what theme do you want to create and choose a proper and internal name.

The internal name should be one of these:

* The full name of the theme, but in camel case: special characters like `&` are removed, each word except the first starts with a capital letter and the first word is lowercase.
* The full name of the theme, but in camel case: without spaces, special characters like `&` are removed, each word except the first starts with a capital letter and the first word is lowercase.
* An abbreviation of the full name of the theme.

For example, if you are creating a theme named `Lava`, the internal name should be `lava`.
Expand Down

0 comments on commit 353e906

Please sign in to comment.