-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (122 loc) · 3.87 KB
/
deploy.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Deploy
on:
workflow_dispatch:
inputs:
job:
description: Job to run
required: true
type: choice
options:
- cli
default: cli
semver:
description: Bump version
required: true
type: choice
options:
- patch
- minor
- major
default: patch
build-docker:
description: Release companion Docker and Action Docker images
type: boolean
default: true
jobs:
deploy-cli:
if: ${{ github.event.inputs.job == 'cli' }}
runs-on: ubuntu-latest
outputs:
version: ${{steps.version-out.outputs.version}}
env:
DIR: apps/cli
steps:
- uses: actions/[email protected]
with:
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install deps
run: cd ${{env.DIR}} && npm install
- name: Run test
run: cd ${{env.DIR}} && npm run test
- name: Compile
run: cd ${{env.DIR}} && npm run build
- name: Bump version
run: cd ${{env.DIR}} && npm version ${{github.event.inputs.semver}}
- name: NPM Publish
id: publish
uses: JS-DevTools/[email protected]
with:
token: ${{ secrets.NPM_TOKEN }}
package: ${{env.DIR}}
ignore-scripts: false
- name: Export version to Docker jobs
id: version-out
run: echo "version=${{steps.publish.outputs.version}}" >> $GITHUB_OUTPUT
- name: Commit package.json changes
uses: EndBug/[email protected]
with:
author_name: Sokari
author_email: [email protected]
message: "Release CLI version ${{ steps.publish.outputs.version }}"
add: '${{ env.DIR }}/*.json'
push: 'origin main --force'
tag: 'v${{steps.publish.outputs.version}} --force'
deploy-docker-action:
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }}
runs-on: ubuntu-latest
needs: deploy-cli
env:
DIR: apps/action
steps:
- uses: actions/[email protected]
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: ${{env.DIR}}
file: ${{env.DIR}}/action.Dockerfile
platforms: linux/amd64
push: true
build-args: CLI_VERSION=${{needs.deploy-cli.outputs.version}}
tags: |
sokari/allure-deployer-action:${{needs.deploy-cli.outputs.version}}
sokari/allure-deployer-action:${{ github.sha }}
deploy-docker:
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }}
runs-on: ubuntu-latest
needs: deploy-cli
env:
DIR: apps/docker
steps:
- uses: actions/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: ${{env.DIR}}
file: ${{env.DIR}}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: CLI_VERSION=${{needs.deploy-cli.outputs.version}}
tags: |
sokari/allure-deployer:latest
sokari/allure-deployer:${{ github.sha }}
sokari/allure-deployer:${{needs.deploy-cli.outputs.version}}