Skip to content

Commit

Permalink
feat(ci): build on every commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnritzdoge committed Apr 9, 2021
1 parent 4aac817 commit 443070b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 53 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/cd-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,56 +43,3 @@ jobs:
- name: "[POST] Clean up failed release"
if: failure()
run: git reset HEAD^ && git push --force
build:
name: Build
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
steps:
- name: "[INIT] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "[INIT] Setup Node.js ${{ matrix.node }}"
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: "[INIT] Restore dependency cache"
id: cache-restore
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- name: "[INIT] Install dependencies"
if: ${{ !steps.cache-restore.outputs.cache-hit }}
run: npm ci
- name: "[EXEC] Build"
run: npm run build
- name: "[EXEC] Update build branch"
run: |
git pull || true
git config --global user.name 'Kludge Cyber Systems (CI)'
git config --global user.email contact@kludge-cs.co.uk
mkdir $GITHUB_WORKSPACE/../transfer
PACKAGE_VERSION=$(node -pe "require('./package.json').version")
npm pack
cp *.tgz $GITHUB_WORKSPACE/../transfer
if [[ $(git checkout build) ]]; then
echo -e "# Using existing build"
git restore --staged . || true
else
echo -e "# Creating orphan build"
git checkout --orphan build
git rm --cached -r .
git commit --allow-empty -m 'chore: initial commit' || true
fi
git clean -fdx && git reset --hard HEAD
git rm -rf . && cp -r $GITHUB_WORKSPACE/../transfer/*.tgz ./
tar -xf *.tgz && rm *.tgz
git add .
git commit -m "build: v${PACKAGE_VERSION}" || true
git push --set-upstream origin build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "CI: Build"
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
steps:
- name: "[INIT] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "[INIT] Setup Node.js ${{ matrix.node }}"
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: "[INIT] Restore dependency cache"
id: cache-restore
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- name: "[INIT] Install dependencies"
if: ${{ !steps.cache-restore.outputs.cache-hit }}
run: npm ci
- name: "[EXEC] Build"
run: npm run build
- name: "[EXEC] Update build branch"
run: |
git pull || true
git config --global user.name 'Kludge Cyber Systems (CI)'
git config --global user.email contact@kludge-cs.co.uk
mkdir $GITHUB_WORKSPACE/../transfer
PACKAGE_VERSION=$(node -pe "require('./package.json').version")
npm pack
cp *.tgz $GITHUB_WORKSPACE/../transfer
if [[ $(git checkout build) ]]; then
echo -e "# Using existing build"
git restore --staged . || true
else
echo -e "# Creating orphan build"
git checkout --orphan build
git rm --cached -r .
git commit --allow-empty -m 'chore: initial commit' || true
fi
git clean -fdx && git reset --hard HEAD
git rm -rf . && cp -r $GITHUB_WORKSPACE/../transfer/*.tgz ./
tar -xf *.tgz && rm *.tgz
git add .
git commit -m "build: v${PACKAGE_VERSION}" || true
git push --set-upstream origin build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 443070b

Please sign in to comment.