-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (91 loc) · 3.1 KB
/
sulmo_ci.yaml
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
name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
version:
description: 'enter version(x.y.z)'
required: true
default: '1.0.0'
container_arch:
type: choice
description: 'choose container architecture'
default: linux/amd64
options:
- "linux/amd64"
- "linux/amd64,linux/arm64"
env:
ARCH: ${{ github.event.inputs.container_arch }}
VERSION: ${{ github.event.inputs.version }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.MY_TOKEN }}
- name: Log File Contents 1
run: |
file_path="./package.json"
cat "$file_path"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Restore cached node_modules
id: restore-node-cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-modules-
- name: Install dependencies
if: steps.restore-node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Change version
run: |
converted_version=$(echo ${{ env.VERSION }} | sed -E 's/^([0-9]+\.[0-9]+)\.([a-zA-Z]+)/\1.0-\2/')
npm version $converted_version --no-git-tag-version --allow-same-version --no-commit-hooks --include-workspace-root -w=web
echo "converted_version=$converted_version" >> "$GITHUB_OUTPUT"
- name: Configure git
run: |
git config --global user.email "${{ vars.GIT_EMAIL }}"
git config --global user.name "${{ vars.GIT_USERNAME }}"
- name: Check if there are any changes
id: check_changes
run: |
git diff --exit-code --quiet || echo "::set-output name=changed::true"
continue-on-error: true
- name: Commit changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git commit -am "chore: version ${{ env.VERSION }}"
- name: Push changes
if: steps.check_changes.outputs.changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.MY_TOKEN }}
branch: ${{ github.ref }}
- name: Install dependencies
run: npm install
- name: Build Vue.js app
run: npm run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log File Contents 2
run: |
file_path="./package.json"
cat "$file_path"
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: ${{ env.ARCH }}
tags: sulmo/vue-app:${{ env.VERSION }}