-
-
Notifications
You must be signed in to change notification settings - Fork 19
154 lines (147 loc) · 6.13 KB
/
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Deploy
on:
# Build and deploy the image on pushes to main branch
workflow_dispatch:
inputs:
reason:
required: true
description: "Reason for running this workflow"
use_test_image:
required: false
type: boolean
description: "Use base image testpr"
default: false
build_latest_as_test:
required: false
type: boolean
description: "Build latest as test"
default: false
push:
branches:
- main
paths:
- "acarshub-typescript/**"
- "Dockerfile.acarshub"
- "Dockerfile.acarshub-nextgen"
- "rootfs/**"
- "version"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
workflow-dispatch:
name: Triggered via Workflow Dispatch?
# only run this step if workflow dispatch triggered
# log the reason the workflow dispatch was triggered
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.reason != ''
runs-on: ubuntu-latest
steps:
- name: Log dispatch reason
env:
INPUTS_REASON: ${{ github.event.inputs.reason }}
INPUTS_USE_TEST_IMAGE: ${{ github.event.inputs.use_test_image }}
INPUTS_BUILD_LATEST_AS_TEST: ${{ github.event.inputs.build_latest_as_test }}
run: |
echo "Workflow dispatch reason: $INPUTS_REASON"
echo "Use test image: $INPUTS_USE_TEST_IMAGE"
echo "Build latest as test: $INPUTS_BUILD_LATEST_AS_TEST"
patch_acars_hub_verison:
name: "patch acars-hub version"
runs-on: ubuntu-latest
outputs:
acarshub_version: ${{ steps.patch.outputs.acarshub_version }}
version: ${{ steps.patch.outputs.version }}
build_number: ${{ steps.patch.outputs.build_number }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: patch
id: patch
run: |
# get the version from version-nextgen. First line only
VERSION=$(head -n 1 version-nextgen)
# get the build number from the github run
BUILD_NUMBER=$GITHUB_RUN_NUMBER
echo "ACARS Hub: $VERSION Build $BUILD_NUMBER"
echo "sed statement in next step will look like"
echo "\#patch acarshub version/sed -i s\/Pre-Release\/$OUTPUT\/g"
OUTPUT="ACARS Hub: $VERSION Build $BUILD_NUMBER"
# set the output in github env
echo "acarshub_version=$OUTPUT" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
deploy:
name: Deploy
if: |
github.event.inputs.build_latest_as_test == 'false' ||
github.event.inputs.build_latest_as_test == ''
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
needs: patch_acars_hub_verison
with:
push_enabled: true
push_destinations: ghcr.io
ghcr_repo_owner: ${{ github.repository_owner }}
ghcr_repo: ${{ github.repository }}
# set build_latest to true if github.event.inputs.use_test_image is false
build_latest: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }}
build_baseimage_test: ${{ github.event.inputs.use_test_image == 'true' }}
# only build the entire stack if we are not using the test image
build_version_specific: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }}
build_platform_specific: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }}
build_nohealthcheck: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }}
build_baseimage_url: :python/:python-test-pr
get_version_method: file_in_container:file=/acarshub_version
dockerfile_changes: |
\# patch acarshub version/sed -i \"s\/Pre-Release\/${{ needs.patch_acars_hub_verison.outputs.acarshub_version}}\/g\" \/acarshub-typescript\/src\/helpers\/menu.ts
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
deploy_test:
name: Deploy as test
if: |
github.event.inputs.build_latest_as_test == 'true' &&
(github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '')
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
needs: patch_acars_hub_verison
with:
push_enabled: true
push_destinations: ghcr.io
ghcr_repo_owner: ${{ github.repository_owner }}
ghcr_repo: ${{ github.repository }}
# set build_latest to true if github.event.inputs.use_test_image is false
build_latest: true
build_baseimage_test: false
# only build the entire stack if we are not using the test image
build_version_specific: false
build_platform_specific: false
build_nohealthcheck: false
build_baseimage_url: :python/:python-test-pr
get_version_method: file_in_container:file=/acarshub_version
docker_latest_tag: test
dockerfile_changes: |
\# patch acarshub version/sed -i \"s\/Pre-Release\/${{ needs.patch_acars_hub_verison.outputs.acarshub_version}}\/g\" \/acarshub-typescript\/src\/helpers\/menu.ts
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
# generate a release
release:
name: Release
needs: [deploy, patch_acars_hub_verison]
runs-on: ubuntu-latest
if: |
(github.event.inputs.use_test_image == 'false' ||
github.event.inputs.use_test_image == '' ) &&
(github.event.inputs.build_latest_as_test == 'false' ||
github.event.inputs.build_latest_as_test == '' )
steps:
- name: Checkout
uses: actions/[email protected]
- name: Create Release
uses: ncipollo/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ needs.patch_acars_hub_verison.outputs.version }}Build${{ needs.patch_acars_hub_verison.outputs.build_number }}
name: ${{ needs.patch_acars_hub_verison.outputs.version }} Build ${{ needs.patch_acars_hub_verison.outputs.build_number }}
draft: false
prerelease: false