forked from garris/BackstopJS
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (59 loc) · 1.85 KB
/
docker-build.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Docker Build & Push
on:
pull_request:
branches: [master, develop]
workflow_dispatch:
workflow_call:
permissions:
checks: write
contents: write
pull-requests: write
packages: write
env:
BRANCH_NAME: ${{ github.event.pull_request.head_ref || github.event.pull_request.head.ref_name || github.head_ref || github.ref_name }}
NODE_VERSION: 20
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
name: 🐳 Build and Push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref }}
- name: Set Name and Tag Vars
env:
name: "${{ env.BRANCH_NAME }}"
run: |
echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV}
echo "TAG=${name/\//-}" >> $GITHUB_ENV
echo "PV=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ⬢ Setup Node & Cache
uses: actions/setup-node@v3
with:
cache: "npm"
cache-dependency-path: package-lock.json
- name: ↧ Install
run: npm ci
- name: 🐳 Build Docker Builder
run: |
npm run init-docker-builder
- name: 🐳 Build Docker
run: |
npm run build-docker
- name: 🐳 Load Docker
run: |
npm run load-docker
- name: 🐳 Push to ghcr.io
run: |
docker tag backstopjs/backstopjs:$PV $REGISTRY/$IMAGE_NAME_LC:$TAG
docker push $REGISTRY/$IMAGE_NAME_LC:$TAG