-
Notifications
You must be signed in to change notification settings - Fork 9
53 lines (53 loc) · 1.78 KB
/
build-and-push.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Build & push
on:
push:
branches-ignore: [ master ]
jobs:
build:
name: Build & push
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Get Yarn cache folder path
id: yarn-cache-folder
run: echo "path=$( yarn cache dir )" >> $GITHUB_OUTPUT
- name: Set up Yarn cache
id: yarn-cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node packages via Yarn
run: yarn install --frozen-lockfile --cache-folder ${{ steps.yarn-cache-folder.outputs.path }}
- name: Build
run: yarn build
- name: Check for changes
id: check-for-changes
run: |
{
echo "diff<<EOF"
git diff
echo "EOF"
} >> "$GITHUB_OUTPUT"
- if: ${{ steps.check-for-changes.outputs.diff != '' }}
name: Configure Git
run: |
git config user.email "[email protected]"
git config user.name $GITHUB_ACTOR
- if: ${{ steps.check-for-changes.outputs.diff != '' }}
name: Stage distribution directory
run: git stage ./dist
- if: ${{ steps.check-for-changes.outputs.diff != '' }}
name: Push the distribution file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -m "Update distribution file"
git push --force "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY" "HEAD:$GITHUB_REF"