-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (100 loc) · 3.48 KB
/
build-deploy.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build & Deploy
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.ref }}
permissions:
contents: write
jobs:
build-deploy:
# runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules
- name: Cache .yarn
id: cache-dot-yarn
uses: actions/cache@v4
with:
path: .yarn
key: ${{ runner.os }}-dot-yarn
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- name: install dependencies
run: |
corepack enable
yarn install
- name: lint
run: yarn lint
- name: build
run: yarn build
- name: Set up Docker Context for Buildx
if: github.ref == 'refs/heads/main'
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
install: true
endpoint: builders
- name: Login to harbor.riwi.dev registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: harbor.riwi.dev
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: set version
if: github.ref == 'refs/heads/main'
run: echo "TAG_VERSION=$(date +'%y-%m-%d').$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
if: github.ref == 'refs/heads/main'
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: true
cache-from: type=registry,ref=harbor.riwi.dev/philiplehmann/cv:buildcache
cache-to: type=registry,ref=harbor.riwi.dev/philiplehmann/cv:buildcache,mode=max,image-manifest=true
tags: |
harbor.riwi.dev/philiplehmann/cv:latest
harbor.riwi.dev/philiplehmann/cv:${{ env.TAG_VERSION }}
- name: git pull
if: github.ref == 'refs/heads/main'
run: |
git pull --rebase --autostash
- uses: philiplehmann/[email protected]
if: github.ref == 'refs/heads/main'
- name: set image tag
if: github.ref == 'refs/heads/main'
run: |
cd kustomize/cv
kustomize edit set image harbor.riwi.dev/philiplehmann/cv=harbor.riwi.dev/philiplehmann/cv:${{ env.TAG_VERSION }}
- name: Commit & Push changes
if: github.ref == 'refs/heads/main'
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: Set image tag to `${{ env.TAG_VERSION }}`