Skip to content

Commit

Permalink
Add Github Action to update design-tokens-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
taysea committed Sep 13, 2024
1 parent 59a8681 commit a2bb8b3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/update-design-tokens-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update design-tokens-stable
on:
push:
branches:
- hpe-design-tokens

jobs:
update-design-tokens-stable:
runs-on: ubuntu-latest
steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18.18.0'

- name: Set NPM version
run: npm install -g [email protected]

- name: Clone repo
uses: actions/checkout@v3

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build
- name: Update design-tokens-stable
run: |
git config --global user.name "Grommet Community Bot"
git config --global user.email "[email protected]"
yarn release-stable
env:
GH_TOKEN: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
20 changes: 15 additions & 5 deletions tools/release-stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ import { simpleGit as git } from 'simple-git';

const repoURL = `https://${process.env.GH_TOKEN}@github.com/grommet/grommet-theme-hpe.git`;
const localFolder = path.resolve('.tmp/grommet-theme-hpe');
const localDist = path.resolve('dist');
const BUILD_DIR = 'dist';
const localDist = path.resolve(BUILD_DIR);

const BRANCH = 'design-tokens-stable';

const files = ['package.json', 'README.md', 'LICENSE'];

if (process.env.CI) {
del(localFolder).then(() => {
git()
.clone(repoURL, localFolder)
.then(() => git(localFolder).checkout('stable'))
.then(() => git(localFolder).checkout(BRANCH))
.then(() => del([`${localFolder}/**/*`]))
.then(() => fs.copy(localDist, localFolder))
.then(() => fs.copy(localDist, `${localFolder}/${BUILD_DIR}`))
.then(() =>
files.forEach((file) =>
fs.copyFile(path.resolve(file), `${localFolder}/${file}`),
),
)
.then(() => git(localFolder).add(['--all', '.']))
.then(() => git(localFolder).commit('stable updated'))
.then(() => git(localFolder).push('origin', 'stable'))
.then(() => git(localFolder).commit(`${BRANCH} updated`))
.then(() => git(localFolder).push('origin', BRANCH))
.catch((err) => console.error('failed: ', err));
});
} else {
Expand Down

0 comments on commit a2bb8b3

Please sign in to comment.