-
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.
fix: Prettier action to write to files (#37)
* feat: test prettier with token * Prettified Code! * feat: test permissions * feat: test permission * Prettified Code! * feat: update permissions * feat: test contents write * Prettified Code! * feat: use token for permissions * Prettified Code! * feat: use separate workflow for prettier * feat: check prettier * fix: prettier yml * fix: test branch trigger and prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * feat: test linter * feat: test prettier * Prettified Code! * feat: test token * feat: add space * feat: test prettier * feat: test prettier * feat: test prettier * feat: test prettier * Prettified Code! * feat: test prettier * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * fix: add needs * Prettified Code! * feat: test prettier * fix: fix yaml * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * feat: test prettier * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test prettier * Prettified Code! * feat: test linter fixing * feat: test linter fix * feat: test liinter fix * feat: test linter fix * feat: test linter fix * feat: test lint fix * fiix: update yml * chore: fix linting issues * feat: update linter * feat: update linter * feat: update yaml * feat: update yaml * feat: update yaml * feat: test liniter * feat: update yaml * feat: update yaml * feat: test linter * feat: update to use pretttier yaml * feat: update yaml * feat: update yaml * feat: test linter * feat: test lint * feat: test linter * Prettified Code! * feat: test linter * Prettified Code! * feat: add comment * fix: format * feat: update yaml * feat: test liinter * Prettified Code! * feat: test same commit * feat: test signing * Prettified Code! * feat: update yml options --------- Co-authored-by: andrew-field <[email protected]>
- Loading branch information
1 parent
a4cd378
commit 327aec4
Showing
6 changed files
with
69 additions
and
31 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
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: prettier-lint | ||
# The super linter has some fix mode options available but it did not work, too complicated. | ||
|
||
on: | ||
push: | ||
branches: | ||
- "release-please--branches--master" # Only trigger for the release-please branch. | ||
|
||
# Permissions for the GITHUB_TOKEN. | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
prettier: | ||
name: Prettify code base # Mainly lint the automaic change log file created by release-please, which is on the release-please branch. | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
# Make sure the actual branch is checked out when running on pull requests. | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: "Import GPG key" # Import the GPG key to sign the commits. | ||
id: import-gpg | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} # Accessed via the secrets context. Needs to be added as a secret. | ||
passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
|
||
- name: Prettify code | ||
uses: creyD/[email protected] | ||
with: | ||
# Prettify the markdown files. | ||
# It uses the default GITHUB_TOKEN which has enough permissions for this command, but would fail if trying to alter the yml files | ||
# in the .github/workflows directory which requires workflows privileges. | ||
# Pushing code using the GITHUB_TOKEN will not trigger any workflows relying on push events. | ||
prettier_options: --write **/*.md | ||
commit_options: -S # Sign the commit with the GPG key. | ||
lint: | ||
# The reusable workflow calls checkout again so the latest code with the prettier changes is checked out. | ||
name: Call super linter | ||
needs: prettier | ||
uses: andrew-field/reusable-workflows/.github/workflows/super-linter.yml@master | ||
with: | ||
# Includes the latest commit from the prettier action. Using github.head_ref would just give the branch name and the latest commit would not be available. | ||
checkout_ref: ${{ github.ref }} |
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
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
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,30 +6,16 @@ on: | |
pull_request: | ||
branches: [master] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
# Allows you to run this workflow manually from the Actions tab. | ||
workflow_dispatch: | ||
|
||
# Permissions for the GITHUB_TOKEN. | ||
permissions: {} | ||
|
||
jobs: | ||
prettier: | ||
if: github.head_ref == 'release-please--branches--master' | ||
name: Prettify code base # Mainly lint the automaic change log file created by release-please, which is on the release-please branch. | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
# Make sure the actual branch is checked out when running on pull requests | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Prettify code | ||
uses: creyD/[email protected] | ||
with: | ||
prettier_options: . --write # Prettify all files in the repository. | ||
lint: | ||
if: ${{ always() }} # This job will always run after the prettier job, regardless of the outcome. https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-jobs-in-a-workflow#defining-prerequisite-jobs | ||
needs: prettier | ||
# If the branch is from the release please workflow, don't trigger the linter. It is handled in the prettier workflow. | ||
# No other way currently to filter on pull request triggers using the source branch as well as the target branch. | ||
if: ${{ github.head_ref != 'release-please--branches--master' }} # Access using the github context. Curly braces are technically optional in if expressions. | ||
name: Lint code base | ||
uses: andrew-field/reusable-workflows/.github/workflows/super-linter.yml@master |