-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a25a3b1
commit eabc5ce
Showing
7 changed files
with
83 additions
and
48 deletions.
There are no files selected for viewing
Binary file not shown.
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,5 @@ | ||
--- | ||
'@jakubmazanec/carson-templates': minor | ||
--- | ||
|
||
Adds support for Renovate bot to the GitHub workflows in `workspace` template. |
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,7 +6,8 @@ on: | |
- development | ||
|
||
jobs: | ||
pull_request_check: | ||
check_pull_request: | ||
name: Check pull request | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
|
@@ -15,6 +16,11 @@ jobs: | |
token: ${{secrets.GITHUB_TOKEN}} | ||
fetch-depth: 0 | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Bot" | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
@@ -23,6 +29,7 @@ jobs: | |
run: npm ci | ||
|
||
- name: Check for changes | ||
if: "github.actor != 'renovate[bot]'" | ||
run: | | ||
git config core.filemode false | ||
git_status=$(git status --porcelain) | ||
|
@@ -40,6 +47,7 @@ jobs: | |
run: npm test | ||
|
||
- name: Check for changes | ||
if: "github.actor != 'renovate[bot]'" | ||
run: | | ||
git config core.filemode false | ||
git_status=$(git status --porcelain) | ||
|
@@ -54,4 +62,5 @@ jobs: | |
git config --unset core.filemode | ||
- name: Check for changesets | ||
if: "github.actor != 'renovate[bot]'" | ||
run: npx changeset status --since=origin/development |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Release | |
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
main_branch_release: | ||
release_main_branch: | ||
name: Main branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
@@ -39,7 +39,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -56,7 +56,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -127,7 +127,7 @@ jobs: | |
git merge main --no-verify | ||
git push -u origin development --no-verify | ||
development_branch_release: | ||
release_development_branch: | ||
name: Development branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
@@ -163,7 +163,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -180,7 +180,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -220,11 +220,13 @@ jobs: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
feature_branch_release: | ||
release_feature_branch: | ||
name: Feature branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
if: "github.ref_name != 'main' && github.ref_name != 'development'" | ||
if: | ||
"github.ref_name != 'main' && github.ref_name != 'development' && github.actor != | ||
'renovate[bot]'" | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
|
@@ -256,7 +258,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -273,7 +275,7 @@ jobs: | |
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ on: | |
- development | ||
|
||
jobs: | ||
pull_request_check: | ||
check_pull_request: | ||
name: Check pull request | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
|
@@ -19,6 +20,11 @@ jobs: | |
token: ${{secrets.GITHUB_TOKEN}} | ||
fetch-depth: 0 | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Bot" | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
@@ -27,6 +33,7 @@ jobs: | |
run: npm ci | ||
|
||
- name: Check for changes | ||
if: "github.actor != 'renovate[bot]'" | ||
run: | | ||
git config core.filemode false | ||
git_status=$(git status --porcelain) | ||
|
@@ -44,6 +51,7 @@ jobs: | |
run: npm test | ||
|
||
- name: Check for changes | ||
if: "github.actor != 'renovate[bot]'" | ||
run: | | ||
git config core.filemode false | ||
git_status=$(git status --porcelain) | ||
|
@@ -58,4 +66,5 @@ jobs: | |
git config --unset core.filemode | ||
|
||
- name: Check for changesets | ||
run: npx changeset status --since=origin/development | ||
if: "github.actor != 'renovate[bot]'" | ||
run: npx changeset status --since=origin/<%- getDevelopmentBranch(workspace) %> |
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,7 +7,7 @@ name: Release | |
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
main_branch_release: | ||
release_main_branch: | ||
name: Main branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
@@ -43,7 +43,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -60,7 +60,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -131,7 +131,7 @@ jobs: | |
git merge <%- getMainBranch(workspace) %> --no-verify | ||
git push -u origin <%- getDevelopmentBranch(workspace) %> --no-verify | ||
|
||
development_branch_release: | ||
release_development_branch: | ||
name: Development branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
@@ -167,7 +167,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -184,7 +184,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -224,11 +224,11 @@ jobs: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
feature_branch_release: | ||
release_feature_branch: | ||
name: Feature branch release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
if: "github.ref_name != '<%- getMainBranch(workspace) %>' && github.ref_name != '<%- getDevelopmentBranch(workspace) %>'" | ||
if: "github.ref_name != '<%- getMainBranch(workspace) %>' && github.ref_name != '<%- getDevelopmentBranch(workspace) %>' && github.actor != 'renovate[bot]'" | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
|
@@ -260,7 +260,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
fi | ||
|
@@ -277,7 +277,7 @@ jobs: | |
|
||
if [[ -n $git_status ]]; then | ||
echo "You have uncommitted changes!" | ||
git status --porcelain | ||
git diff | ||
git config --unset core.filemode | ||
exit 1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,43 @@ | ||
name: Generate changeset | ||
--- | ||
to: '.github/workflows/update-pull-request.yaml' | ||
if: 'false' | ||
strategy: overwrite | ||
--- | ||
name: Update pull request | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request_target: | ||
paths: | ||
- '.github/workflows/renovate.yaml' | ||
- '**/package.json' | ||
- '**/package-lock.json' | ||
branches: | ||
- development | ||
|
||
jobs: | ||
generate-changeset: | ||
name: Generate changeset | ||
update_pull_request: | ||
name: Update pull request | ||
if: github.actor == 'renovate[bot]' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
if: github.actor == 'renovate[bot]' | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
token: ${{secrets.PAT}} | ||
token: ${{secrets.GITHUB_TOKEN}} | ||
fetch-depth: 0 | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Bot" | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install packages | ||
run: npm ci | ||
|
||
- name: Generate changeset | ||
uses: actions/github-script@v6 | ||
if: ${{ github.actor == 'renovate[bot]' }} | ||
with: | ||
script: | | ||
let { promises: fs } = require('fs'); | ||
|
@@ -86,14 +91,6 @@ jobs: | |
return bumps; | ||
} | ||
|
||
let branch = await exec.getExecOutput('git branch --show-current'); | ||
if (!branch.stdout.startsWith('renovate/')) { | ||
console.log('Not a renovate branch, skipping...'); | ||
return; | ||
} | ||
let diffOutput = await exec.getExecOutput('git diff --name-only HEAD~1'); | ||
let diffFiles = diffOutput.stdout.split('\n'); | ||
|
||
|
@@ -111,6 +108,11 @@ jobs: | |
if (!packageNames.length) { | ||
console.log('No package.json changes to published packages, skipping...'); | ||
|
||
await exec.exec('npx', ['changeset', '--empty']); | ||
await exec.exec('git', ['add', './.changeset/**', '--all']); | ||
await exec.exec('git commit -m"Add changeset [skip actions]"'); | ||
await exec.exec('git push --force'); | ||
|
||
return; | ||
} | ||
|
||
|
@@ -121,6 +123,14 @@ jobs: | |
let packageBumps = await getBumps(files); | ||
|
||
await createChangeset(fileName, packageBumps, packageNames); | ||
await exec.exec('git', ['add', fileName]); | ||
await exec.exec('git commit -C HEAD --amend --no-edit'); | ||
await exec.exec('git', ['add', './.changeset/**', '--all']); | ||
await exec.exec('git commit -m"Add changeset [skip actions]"'); | ||
await exec.exec('git push --force'); | ||
|
||
- name: Update Carson | ||
if: ${{ github.actor == 'renovate[bot]' }} | ||
run: | | ||
npm install | ||
git add . --all | ||
git commit -m"Run Carson update [skip actions]" | ||
git push --force |