-
Notifications
You must be signed in to change notification settings - Fork 10
130 lines (110 loc) · 4.33 KB
/
docker-client.yml
File metadata and controls
130 lines (110 loc) · 4.33 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Docker Image client
on:
pull_request:
branches: ["main"]
push:
branches: ['**']
paths:
- 'client/**'
- '.github/workflows/docker-client.yml'
- '!client/builder/**'
workflow_dispatch:
branches: ['**']
jobs:
docker-client:
runs-on: ubuntu-latest
outputs:
img_tag: ${{ steps.preserve_img_tag.outputs.img_tag }}
steps:
- uses: actions/checkout@v4
- name: Setup VARS.js
run: 'printf "$AFN_VARS" > client/assets/js/VARS.js'
env:
AFN_VARS : ${{secrets.AFN_VARS}}
- name: Compute image tag
run: |
echo "IMG_TAG=$(echo ${GITHUB_SHA} | sed -E 's/refs\/(heads|tags)\///g' | sed -e 's/\//-/g')" >> $GITHUB_ENV
- name: Preserve image tag
id: preserve_img_tag
run: |
echo "img_tag=${{ env.IMG_TAG }}" >> $GITHUB_OUTPUT
- name: Kaniko build full
uses: julsemaan/action-kaniko@master
with:
registry: ghcr.io
image: julsemaan/anyfile-notepad/client-full
tag: ${{ env.IMG_TAG }}
tag_with_latest: false
password: ${{ secrets.GITHUB_TOKEN }}
cache: true
cache_registry: ghcr.io/julsemaan/anyfile-notepad/client-full/cache
path: client/
extra_args: >-
--push-retry 5
--build-arg=AFN_BUILD_ID=gha-${{ github.run_id }}
- name: Kaniko build light
uses: julsemaan/action-kaniko@master
with:
registry: ghcr.io
image: julsemaan/anyfile-notepad/client-light
tag: ${{ env.IMG_TAG }}
tag_with_latest: false
password: ${{ secrets.GITHUB_TOKEN }}
cache: true
cache_registry: ghcr.io/julsemaan/anyfile-notepad/client-light/cache
path: client/light/
extra_args: >-
--push-retry 5
--build-arg=SRC_IMAGE=ghcr.io/julsemaan/anyfile-notepad/client-full:${{ env.IMG_TAG }}
pr_afn_k8s:
needs: docker-client
concurrency:
group: prs-to-afn-k8s
cancel-in-progress: false
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: julsemaan/afn-k8s
token: ${{ secrets.GHA_REPO_TOKEN }}
fetch-depth: 0
- uses: frenck/action-setup-yq@v1
- name: PR tag change to afn-k8s
if: github.ref != 'refs/heads/beta'
env:
IMG_TAG: ${{needs.docker-client.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: appProdImage
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# Checkout the remote ref if it already exist, otherwise, start from main
git checkout origin/$BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.backend.'$CHANGE_TYPE'.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'
- name: PR tag change to afn-k8s
if: github.ref == 'refs/heads/beta'
env:
IMG_TAG: ${{needs.docker-client.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: appDevImage
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# The branch already exists from the previous step
git checkout $BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.backend.'$CHANGE_TYPE'.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'