Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit dcda939

Browse files
authored
chore(ci): perform template update from github action (#575)
1 parent 9955ed3 commit dcda939

File tree

4 files changed

+70
-41
lines changed

4 files changed

+70
-41
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: release-templates
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version: '14'
17+
18+
- name: 📦 install dependencies
19+
run: yarn install
20+
21+
- name: 🔧 build templates
22+
run: yarn release-templates
23+
24+
- name: 🚀 push templates
25+
run: |
26+
cd build
27+
UNCOMMITTED_CHANGES=`git status --porcelain`
28+
if [ ! -z "$UNCOMMITTED_CHANGES" ]; then
29+
git config --global user.name "InstantSearch"
30+
git config --global user.email "[email protected]"
31+
git commit -a -m "feat(template): Update templates"
32+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
33+
git push origin templates
34+
echo "✅ Templates have been compiled to the branch templates."
35+
else
36+
echo "ℹ️ No changes made to the templates."
37+
fi

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,9 @@ Create InstantSearch App is [MIT licensed](LICENSE).
162162

163163
[version-svg]: https://img.shields.io/npm/v/create-instantsearch-app.svg?style=flat-square
164164
[package-url]: https://npmjs.org/package/create-instantsearch-app
165-
[ci-svg]: https://img.shields.io/travis/algolia/create-instantsearch-app/master.svg?style=flat-square
166-
[ci-url]: https://travis-ci.org/algolia/create-instantsearch-app
167165
[ci-svg]: https://img.shields.io/circleci/project/github/algolia/create-instantsearch-app.svg?style=flat-square
168166
[ci-url]: https://circleci.com/gh/algolia/create-instantsearch-app
169-
[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
167+
[license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
170168
[license-url]: LICENSE
171169

172170
<!-- Links -->

scripts/release-templates.js

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -104,53 +104,48 @@ async function build() {
104104
})
105105
);
106106

107-
// Change directory to the build folder to execute Git commands
108-
process.chdir(BUILD_FOLDER);
107+
if (!process.env.GITHUB_ACTION) {
108+
// Change directory to the build folder to execute Git commands
109+
process.chdir(BUILD_FOLDER);
109110

110-
const uncommitedChanges = execSync('git status --porcelain')
111-
.toString()
112-
.trim();
111+
const uncommitedChanges = execSync('git status --porcelain')
112+
.toString()
113+
.trim();
113114

114-
if (uncommitedChanges) {
115-
// Stage all new demos to Git
116-
execSync('git add -A');
115+
if (uncommitedChanges) {
116+
// Stage all new demos to Git
117+
execSync('git add -A');
117118

118-
// Commit the new demos
119-
const commitMessage = 'feat(template): Update templates';
119+
// Commit the new demos
120+
const commitMessage = 'feat(template): Update templates';
120121

121-
console.log('▶︎ Commiting');
122-
console.log();
123-
console.log(` ${chalk.cyan(commitMessage)}`);
122+
console.log('▶︎ Commiting');
123+
console.log();
124+
console.log(` ${chalk.cyan(commitMessage)}`);
124125

125-
execSync(`git commit -m "${commitMessage}"`);
126+
execSync(`git commit -m "${commitMessage}"`);
126127

127-
// Use the `origin-with-token` remote if it exists (when run with Ship.js)
128-
const origin = execSync(
129-
`git remote | grep origin-with-token || echo origin`
130-
)
131-
.toString()
132-
.trim();
128+
// Push the new demos to the `templates` branch
129+
console.log();
130+
console.log(`▶︎ Pushing to branch "${chalk.green(TEMPLATES_BRANCH)}"`);
131+
execSync(`git push origin ${TEMPLATES_BRANCH}`);
133132

134-
// Push the new demos to the `templates` branch
135-
console.log();
136-
console.log(`▶︎ Pushing to branch "${chalk.green(TEMPLATES_BRANCH)}"`);
137-
execSync(`git push ${origin} ${TEMPLATES_BRANCH}`);
133+
console.log();
134+
console.log(
135+
`✅ Templates have been compiled to the branch "${chalk.green(
136+
TEMPLATES_BRANCH
137+
)}".`
138+
);
139+
} else {
140+
console.log();
141+
console.log('ℹ️ No changes made to the templates.');
142+
}
138143

139144
console.log();
140-
console.log(
141-
`✅ Templates have been compiled to the branch "${chalk.green(
142-
TEMPLATES_BRANCH
143-
)}".`
144-
);
145-
} else {
146-
console.log();
147-
console.log('ℹ️ No changes made to the templates.');
148-
}
149-
150-
console.log();
151-
process.chdir('..');
145+
process.chdir('..');
152146

153-
cleanup();
147+
cleanup();
148+
}
154149
}
155150

156151
build().catch(err => {

ship.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ module.exports = {
77
return true;
88
},
99
buildCommand: () => null,
10-
afterPublish: ({ exec }) => exec('yarn run release-templates'),
1110
};

0 commit comments

Comments
 (0)