Skip to content

Merge pull request #1247 from sdr-enthusiasts/dependabot/pip/rootfs/w… #1287

Merge pull request #1247 from sdr-enthusiasts/dependabot/pip/rootfs/w…

Merge pull request #1247 from sdr-enthusiasts/dependabot/pip/rootfs/w… #1287

Workflow file for this run

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/checkout@v4.1.7
- 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/checkout@v4.1.7
- name: Create Release
uses: ncipollo/release-action@v1.14.0
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