-
-
Notifications
You must be signed in to change notification settings - Fork 9
88 lines (73 loc) · 2.84 KB
/
docker.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Docker
on:
release:
types: [published]
workflow_dispatch:
jobs:
release:
name: Build latest docker release
runs-on: ubuntu-latest
env:
GITHUB_URL: https://github.com/${{ github.repository }}
IMAGE: ulixee/ulixee-cloud
steps:
- uses: actions/checkout@v4
- name: Read version
shell: bash
working-directory: cloud/main
run: export VERSION=$(node -p "require('./package.json').version") && echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install yarn packages
run: yarn install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Determine Chrome Versions
shell: bash
run: |
CHROME_PACKAGE=$(yarn list --pattern '@ulixee/chrome-' --depth=0 | grep '@ulixee/chrome-' | grep -Eo 'chrome-[0-9]+-0' | head -1)
CHROME_VERSION=$(echo $CHROME_PACKAGE | awk -F'-' '{print $2}')
PREVIOUS_CHROME_VERSION=$((CHROME_VERSION - 1))
echo "ADD_CHROME_VERSION=$PREVIOUS_CHROME_VERSION" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
shell: bash
working-directory: cloud/tools/docker
run: |
export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "Building Docker image: ${VERSION}"
docker build \
--progress auto \
--cache-from ghcr.io/${IMAGE}:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
\
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg GITHUB_SHA=${GITHUB_SHA} \
--build-arg ADD_TO_INSTALL="yarn add "@ulixee/chrome-$ADD_CHROME_VERSION-0"" \
--build-arg VERSION=${VERSION} \
\
--tag ghcr.io/${IMAGE}:v${VERSION} \
--tag ghcr.io/${IMAGE}:latest \
--tag docker.io/${IMAGE}:v${VERSION} \
--tag docker.io/${IMAGE}:latest \
\
--label org.label-schema.build-date=${BUILD_DATE} \
--label org.label-schema.vcs-url=${GITHUB_URL} \
--label org.label-schema.vcs-ref=${GITHUB_SHA} \
\
--label org.opencontainers.image.created=${BUILD_DATE} \
--label org.opencontainers.image.source=${GITHUB_URL} \
--label org.opencontainers.image.revision=${GITHUB_SHA} \
.
- name: Push Image to GHCR
run: docker push -a ghcr.io/${IMAGE}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Image to Dockerhub
run: docker push -a docker.io/${IMAGE}