-
Notifications
You must be signed in to change notification settings - Fork 14
103 lines (90 loc) · 2.92 KB
/
ci.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
name: Continuous Integration
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
on:
push:
branches:
- main
- feat/k8s
tags:
- production*
- staging*
paths-ignore:
- 'k8s/**'
- 'Dockerfile.base'
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🎫 Update patch version
run: |
git fetch
git checkout main
git pull origin main
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
if [[ $GITHUB_REF == refs/tags/production* ]]; then
npm version major
elif [[ $GITHUB_REF == refs/tags/staging* ]]; then
npm version minor
else
npm version patch
fi
git fetch --all
git push origin main
ci:
runs-on: ubuntu-latest
needs: version
# Add concurrency check for base image
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
steps:
# NOTE: Disabled until we have a stable base image
# - name: 🔍 Check for base image workflow
# id: check-workflow
# continue-on-error: true
# uses: lewagon/[email protected]
# with:
# ref: ${{ github.ref }}
# check-name: 'build-and-push-base-image'
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# wait-interval: 10
# allowed-conclusions: success,skipped
# running-workflow-name: 'Build and Push Base Image'
- name: 🛎️ Checkout
uses: actions/checkout@v4
- id: imagename
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
if [[ $GITHUB_REF == refs/tags/production* ]]; then
npm version major
elif [[ $GITHUB_REF == refs/tags/staging* ]]; then
npm version minor
else
npm version patch
fi
- name: 📝 Get Current Version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: 🔐 Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🔧 Build and push Docker Image
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.imagename.outputs.lowercase }}:${{ steps.package-version.outputs.current-version}}