Skip to content

Commit

Permalink
feat(ci): push samples to dedicated branches
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelsimon committed Dec 15, 2023
1 parent 64d3f3c commit 8cc6ac1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ jobs:
env:
GH_TOKEN: ${{ secrets.WOOSMAP_GH_ACCESS_TOKEN }}
NPM_TOKEN: skip
- name: Push samples to branches
run: |
bash ./sample-to-branch.sh
env:
GITHUB_TOKEN: ${{ secrets.WOOSMAP_GH_ACCESS_TOKEN }}
41 changes: 41 additions & 0 deletions sample-to-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e

tmp=`mktemp -d`

for sample in dist/samples/*/; do
name=`basename $sample`
branch="sample/${name}"

pushd $tmp
rm -rf .git
git init
git config user.name 'gaelsimon'
git config user.email 'gael.simon@woosmap.com'

if [ -n "$GITHUB_TOKEN" ]; then
git remote add origin "https://gaelsimon:$GITHUB_TOKEN@github.com/woosmap/js-samples.git"
else
git remote add origin "git@github.com:woosmap/js-samples.git"
fi

git checkout -B $branch
git rm -rqf . || true
git clean -fxd
popd

cp -r $sample/app/* $tmp

# manually copy all files beginning with .
cp $sample/app/.env $tmp/.env
cp $sample/app/.eslintrc.json $tmp/.eslintrc.json
cp $sample/app/.gitignore $tmp/.gitignore


pushd $tmp
git add -A
git commit -am "chore: sync ${name} [skip-ci]" --no-verify || true
git push -q --set-upstream origin $branch -f
git status
popd
done

0 comments on commit 8cc6ac1

Please sign in to comment.