Skip to content

Check FDS Release

Check FDS Release #567

Workflow file for this run

name: Check FDS Release
on:
workflow_dispatch:
schedule:
- cron: '0 5,15 * * *'
jobs:
check-release:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Fetch latest FDS release version
run: |
REGEX_VERSION=[0-9]+\.[0-9]+\.[0-9]+
REGEX_URL=https:.+?lnx.sh
DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/firemodels/fds/releases/latest" --stderr - | \
grep -E "browser_download_url.+?${REGEX_URL}\"$" | \
grep -oEi ${REGEX_URL})
VERSION=$(echo ${DOWNLOAD_URL} | grep -oEi FDS-${REGEX_VERSION}/ | grep -oEi ${REGEX_VERSION})
DOWNLOAD_URL=$(echo ${DOWNLOAD_URL} | sed 's/\//\\\//g')
echo "DOWNLOAD_URL=${DOWNLOAD_URL}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check if branch for release exists
continue-on-error: true
run: |
REGEX_RELEASE=(test/)?${{ env.VERSION }}
echo "NEW_BRANCH=test/${{ env.VERSION }}" >> $GITHUB_ENV
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 -E \"${REGEX_RELEASE}\"
echo "NEW_BRANCH=false" >> $GITHUB_ENV
- name: Checkout repository
if: env.NEW_BRANCH != 'false'
uses: actions/checkout@v4
- name: Create new test branch
if: env.NEW_BRANCH != 'false'
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git switch -c ${{ env.NEW_BRANCH }}
sed -i -E "s/https.+?sh/${{ env.DOWNLOAD_URL }}/g" Dockerfile
git commit -am "FDS ${{ env.VERSION }}"
git push --set-upstream origin ${{ env.NEW_BRANCH }}
- name: Trigger Test
if: env.NEW_BRANCH != 'false'
run: |
curl -L -X POST -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 }}/actions/workflows/test.yaml/dispatches \
-d "{\"ref\":\"${{ env.NEW_BRANCH }}\"}"
keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}