Upgraded to ubuntu:24.04 #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy FDS | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
- 'nightly-[0-9]+.[0-9]+.[0-9]+-[0-9]+' | |
- '!main' | |
- '!test/**' | |
jobs: | |
prepare-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: read | |
outputs: | |
IMAGE_NAME: ${{ steps.image-selector.outputs.IMAGE_NAME }} | |
TAG: ${{ steps.tag-selector.outputs.TAG }} | |
WORKFLOW_ID: ${{ steps.workflow-selector.outputs.WORKFLOW_ID }} | |
IS_LATEST: ${{ steps.latest-selector.outputs.IS_LATEST }} | |
steps: | |
- name: Extract image name | |
id: image-selector | |
run: | | |
if [[ $GITHUB_REF_NAME = nightly* ]] | |
then | |
IMAGE_NAME=fds-nightly | |
else | |
IMAGE_NAME=fds | |
fi | |
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | |
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
- name: Select Tag | |
id: tag-selector | |
run: | | |
TAG=$(echo ${GITHUB_REF_NAME#nightly-} | grep -oEi [0-9]+\.[0-9]+\.[0-9]+) | |
echo "TAG=${TAG}" >> $GITHUB_ENV | |
echo "TAG=${TAG}" >> $GITHUB_OUTPUT | |
- name: Extract Workflow ID | |
id: workflow-selector | |
run: | | |
if [[ ${{ env.IMAGE_NAME }} = *nightly ]] | |
then | |
echo "WORKFLOW_ID=deploy.nightly.yaml" >> $GITHUB_OUTPUT | |
else | |
echo "WORKFLOW_ID=deploy.yaml" >> $GITHUB_OUTPUT | |
fi | |
- name: Check if new build version is latest | |
id: latest-selector | |
continue-on-error: true | |
run: | | |
if [[ ${{ contains(github.ref_name, 'nightly') }} == true ]] | |
then | |
echo "IS_LATEST=false" >> $GITHUB_OUTPUT | |
else | |
REGEX=[0-9]+\.[0-9]+\.[0-9]+ | |
LATEST_VERSION=0.0.0 | |
echo "IS_LATEST=true" >> $GITHUB_OUTPUT | |
VERSIONS=$(curl --silent "https://api.github.com/users/${{ github.repository_owner }}/packages/container/${{ env.IMAGE_NAME }}/versions" --stderr - \ | |
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | \ | |
grep -E "[[:space:]]+\"${REGEX}\"" | grep -oEi ${REGEX}) | |
for VERSION in $VERSIONS; do | |
[ "$VERSION" \> "$LATEST_VERSION" ] && LATEST_VERSION=$VERSION | |
done | |
if [ "${{ env.TAG }}" \< "${LATEST_VERSION}" ] | |
then | |
echo "IS_LATEST=false" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Cleanup test branches | |
continue-on-error: true | |
run: | | |
REGEX_RELEASE="test/(nightly\-)?[0-9]+\.[0-9]+\.[0-9]+(\-[0-9]+)?" | |
BRANCHES=$(curl --silent -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/branches" --stderr - | grep -oEi ${REGEX_RELEASE}) | |
for BRANCH in ${BRANCHES}; do | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git push origin --delete ${BRANCH} | |
done | |
- name: Merge branch into main | |
if: ${{ !contains(github.ref_name, 'nightly') }} | |
run: | | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git fetch --unshallow | |
git switch main | |
REGEX=[0-9]+\.[0-9]+\.[0-9]+ | |
DOCKERFILE_VERSION=$(grep -oEI /FDS-?${REGEX}/ Dockerfile | grep -oEI ${REGEX}) | |
if [ "${{ github.ref_name }}" \> "${DOCKERFILE_VERSION}" ] | |
then | |
git merge origin/${{ github.ref_name }} | |
git push | |
fi | |
docker-hub_build-and-push: | |
needs: [prepare-build] | |
if: ${{ !contains(github.ref_name, 'nightly') }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract image and tags | |
run: | | |
IMAGE=${{ github.repository_owner }}/${{ needs.prepare-build.outputs.IMAGE_NAME }} | |
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV | |
if [[ ${{ needs.prepare-build.outputs.IS_LATEST }} == true ]] | |
then | |
echo "TAGS=${IMAGE}:${{ needs.prepare-build.outputs.TAG }},${IMAGE}:latest" >> $GITHUB_ENV | |
else | |
echo "TAGS=${IMAGE}:${{ needs.prepare-build.outputs.TAG }}" >> $GITHUB_ENV | |
fi | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.TAGS }} | |
labels: ${{ steps.meta.outputs.labels }} | |
ghcr-io_build-and-push: | |
needs: [prepare-build] | |
runs-on: ubuntu-latest | |
env: | |
REGISTRY: ghcr.io | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract image and tags | |
run: | | |
IMAGE=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ needs.prepare-build.outputs.IMAGE_NAME }} | |
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV | |
if [[ ${{ needs.prepare-build.outputs.IS_LATEST }} == true ]] | |
then | |
echo "TAGS=${IMAGE}:${{ needs.prepare-build.outputs.TAG }},${IMAGE}:latest" >> $GITHUB_ENV | |
else | |
echo "TAGS=${IMAGE}:${{ needs.prepare-build.outputs.TAG }}" >> $GITHUB_ENV | |
fi | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.TAGS }} | |
labels: ${{ steps.meta.outputs.labels }} | |
trigger-batchfds-workflow: | |
needs: [prepare-build, ghcr-io_build-and-push] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Check BatchFDS compatibility | |
env: | |
MIN_VERSION: 6.7.1 | |
run: | | |
version_greater_equal() { | |
printf '%s\n%s\n' "$2" "$1" | sort --check=quiet --version-sort | |
} | |
if version_greater_equal ${{ needs.prepare-build.outputs.TAG }} ${MIN_VERSION}; then | |
echo "BUILD_BatchFDS=true" >> $GITHUB_ENV | |
else | |
echo "BUILD_BatchFDS=false" >> $GITHUB_ENV | |
fi | |
- name: Trigger BatchFDS build | |
if: env.BUILD_BatchFDS == 'true' | |
env: | |
TOKEN: ${{ secrets.DISPATCH_WORKFLOWS_PUBLIC_BCL_TOKEN }} | |
ORG: openbcl | |
REPO: batchfds | |
run: | | |
curl -L -X POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Authorization: Bearer ${TOKEN}" \ | |
https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${{ needs.prepare-build.outputs.WORKFLOW_ID }}/dispatches \ | |
-d "{\"ref\":\"main\",\"inputs\": {\"tag\": \"${{ needs.prepare-build.outputs.TAG }}\"}}" | |
trigger-cocafds-workflow: | |
needs: [prepare-build, ghcr-io_build-and-push] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Check CoCaFDS compatibility | |
env: | |
MIN_VERSION: 6.7.5 | |
run: | | |
version_greater_equal() { | |
printf '%s\n%s\n' "$2" "$1" | sort --check=quiet --version-sort | |
} | |
if version_greater_equal ${{ needs.prepare-build.outputs.TAG }} ${MIN_VERSION}; then | |
echo "BUILD_CoCaFDS=true" >> $GITHUB_ENV | |
else | |
echo "BUILD_CoCaFDS=false" >> $GITHUB_ENV | |
fi | |
- name: Trigger BUILD_CoCaFDS build | |
if: env.BUILD_CoCaFDS == 'true' | |
env: | |
TOKEN: ${{ secrets.DISPATCH_WORKFLOWS_PRIVATE_BCL_TOKEN }} | |
ORG: brandschutzconsult | |
REPO: cocafds | |
run: | | |
curl -L -X POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Authorization: Bearer ${TOKEN}" \ | |
https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${{ needs.prepare-build.outputs.WORKFLOW_ID }}/dispatches \ | |
-d "{\"ref\":\"main\",\"inputs\": {\"tag\": \"${{ needs.prepare-build.outputs.TAG }}\"}}" | |
trigger-propti-workflow: | |
needs: [prepare-build, ghcr-io_build-and-push] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Check Propti compatibility | |
env: | |
MIN_VERSION: 6.7.4 | |
run: | | |
version_greater_equal() { | |
printf '%s\n%s\n' "$2" "$1" | sort --check=quiet --version-sort | |
} | |
if version_greater_equal ${{ needs.prepare-build.outputs.TAG }} ${MIN_VERSION}; then | |
echo "BUILD_Propti=true" >> $GITHUB_ENV | |
else | |
echo "BUILD_Propti=false" >> $GITHUB_ENV | |
fi | |
- name: Trigger BUILD_Propti build | |
if: env.BUILD_Propti == 'true' | |
env: | |
TOKEN: ${{ secrets.DISPATCH_WORKFLOWS_PROPTI_TRISTAN_HEHNEN }} | |
ORG: FireDynamics | |
REPO: propti | |
run: | | |
curl -L -X POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Authorization: Bearer ${TOKEN}" \ | |
https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${{ needs.prepare-build.outputs.WORKFLOW_ID }}/dispatches \ | |
-d "{\"ref\":\"master\",\"inputs\": {\"tag\": \"${{ needs.prepare-build.outputs.TAG }}\"}}" |