-
-
Notifications
You must be signed in to change notification settings - Fork 20
129 lines (123 loc) · 4.93 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
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
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 }}
run: |
echo "Workflow dispatch reason: $INPUTS_REASON"
echo "Use test image: $INPUTS_USE_TEST_IMAGE"
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
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 }}
# 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 == ''
steps:
- name: Checkout
uses: actions/[email protected]
- name: Build project # This would actually build your project, using zip for an example artifact
run: |
zip --junk-paths my-artifact README.md
- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.patch_acars_hub_verison.outputs.version }}
release_name: ${{ needs.patch_acars_hub_verison.outputs.version }} Build ${{ needs.patch_acars_hub_verison.outputs.build_number }}
draft: false
prerelease: false
# - name: Upload Release Asset
# id: upload-release-asset
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./
# asset_name: acarshub
# asset_content_type: application/octet-stream