-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from systemphil/fix/ci-checks
fix ci-checks
- Loading branch information
Showing
4 changed files
with
125 additions
and
105 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,17 +7,21 @@ on: | |
|
||
jobs: | ||
formatting: | ||
permissions: | ||
contents: "write" | ||
pull-requests: "write" | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Generate COG token | ||
id: create_token | ||
uses: tibdex/github-app-token@v2 | ||
with: | ||
app_id: ${{ secrets.COG_APP_ID }} | ||
private_key: ${{ secrets.COG_PRIVATE_KEY }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
token: ${{ steps.create_token.outputs.token }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
|
@@ -40,6 +44,6 @@ jobs: | |
git config --global user.email "[email protected]" | ||
if [[ `git status --porcelain` ]]; then | ||
git add . | ||
git commit -m "ci: format code with Prettier [on behalf of ${{ github.event.pull_request.user.login }}]" | ||
git commit -m "ci: format code [automated action on behalf of ${{ github.event.pull_request.user.login }}]" | ||
git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
fi |
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,109 @@ | ||
name: Discarded workflow experiments | ||
|
||
on: | ||
workflow_dispatch: | ||
# inputs: | ||
# pr_id: | ||
# description: 'Pull Request ID' | ||
# required: true | ||
# workflow_run: | ||
# workflows: ["Verify formatting"] | ||
# types: | ||
# - completed | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
# | ||
# ! NOTE, these steps are not meant to be run together, | ||
# ! they are just snippets from different workflows | ||
# | ||
jobs: | ||
formatting: | ||
permissions: | ||
contents: "write" | ||
pull-requests: "write" | ||
actions: "write" | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
token: ${{ steps.create_token.outputs.token }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Get Prettier version from package-lock.json | ||
run: | | ||
PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) | ||
echo $PRETTIER_VERSION | ||
- name: Run Prettier (specific version) | ||
run: | | ||
npx --yes prettier@$PRETTIER_VERSION --config .prettierrc --write . | ||
#extract the latest commit sha from the PR | ||
- name: Check for changes | ||
id: check-changes | ||
run: | | ||
git config --global user.name "sPhil_PR_quality_ctl" | ||
git config --global user.email "[email protected]" | ||
if [[ `git status --porcelain` ]]; then | ||
git add . | ||
git commit -m "ci: format code with Prettier [on behalf of ${{ github.event.pull_request.user.login }}]" | ||
git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
COMMIT_SHA=$(git rev-parse HEAD) | ||
echo "Commit SHA: $COMMIT_SHA" | ||
echo "::set-output name=commit_sha::$COMMIT_SHA" | ||
fi | ||
#extract the latest commit sha from the PR using script | ||
- name: Get sha from PR number and save output | ||
id: get-sha | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
console.log('PR number: ' + ${{ github.event.pull_request.number }}) | ||
const pr = await github.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: ${{ github.event.pull_request.number }} | ||
}) | ||
console.log('PR Head sha: ' + pr.data.head.sha) | ||
core.setOutput('sha', pr.data.head.sha) | ||
#invoke another workflow using custom inputs | ||
- name: Invoke workflow | ||
run: | | ||
echo "SHA: ${{ steps.check-changes.outputs.commit_sha }}" | ||
gh workflow run verify_mdx_content.yaml --ref ${{ github.event.pull_request.head.ref }} -f pr_id=${{ steps.check-changes.outputs.commit_sha }} | ||
# pr_id=${{ steps.get-sha.outputs.sha }} | ||
|
||
#creating checks for the workflow | ||
- name: Report tests check | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.checks.create({ | ||
name: 'prepyrus verification', | ||
head_sha: '${{ github.event.inputs.pr_id }}', | ||
status: 'completed', | ||
conclusion: '${{ steps.prepyrus-run.outcome }}', | ||
output: { | ||
title: 'Prepyrus verification', | ||
summary: 'Results: ${{ steps.prepyrus-run.outcome }}' | ||
}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}) | ||
if: always() | ||
|
||
# head_sha: '${{ github.event.inputs.pr_id }}', |