Update Firely Terminal (Cron Job) #66
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
# This is a workflow to help to update the [Firely Terminal](https://www.nuget.org/packages/Firely.Terminal) dependency automatically | |
name: Update Firely Terminal (Cron Job) | |
on: | |
schedule: | |
# Run every 6 hours | |
- cron: '0 */6 * * *' | |
workflow_dispatch: | |
jobs: | |
check-firely-terminal-updates: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install yq | |
run: | | |
mkdir -p ~/bin | |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O ~/bin/yq | |
chmod +x ~/bin/yq | |
echo "~/bin" >> $GITHUB_PATH | |
- name: Extract with default version of Firely Terminal from the GH action | |
run: | | |
FIRELY_TERMINAL_VERSION=$(yq '.inputs.FIRELY_TERMINAL_VERSION.default' action.yml) | |
echo "FIRELY_TERMINAL_VERSION: '$FIRELY_TERMINAL_VERSION'" | |
echo "FIRELY_TERMINAL_VERSION=$FIRELY_TERMINAL_VERSION" >> $GITHUB_ENV | |
- name: Extract with latest release version of Firely Terminal | |
run: | | |
PACKAGE_URL="https://api.nuget.org/v3/registration5-semver1/firely.terminal/index.json" | |
LATEST_RELEASE=$(wget -qO- "$PACKAGE_URL" | jq -r '.items[-1].items[-1].catalogEntry.version') | |
echo "LATEST_RELEASE: '$LATEST_RELEASE'" | |
echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_ENV | |
- name: Compare versions of Firely Terminal | |
run: | | |
if dpkg --compare-versions "$FIRELY_TERMINAL_VERSION" lt "$LATEST_RELEASE"; then | |
echo "Found outdated version of SUSHI, update recommended." | |
FIRELY_TERMINAL_UDPATE_RECOMMENDED="true" | |
echo "FIRELY_TERMINAL_UDPATE_RECOMMENDED=$FIRELY_TERMINAL_UDPATE_RECOMMENDED" >> $GITHUB_ENV | |
elif dpkg --compare-versions "$FIRELY_TERMINAL_VERSION" gt "$LATEST_RELEASE"; then | |
echo "Unexpected version of SUSHI found, it appears to be higher than the latest release version." | |
exit 1 | |
else | |
FIRELY_TERMINAL_UDPATE_RECOMMENDED="false" | |
echo "FIRELY_TERMINAL_UDPATE_RECOMMENDED=$FIRELY_TERMINAL_UDPATE_RECOMMENDED" >> $GITHUB_ENV | |
echo "Firely Terminal is up-to-date." | |
fi | |
- name: Create patch for Firely Terminal version in action.yml | |
run: | | |
if [[ "$FIRELY_TERMINAL_UDPATE_RECOMMENDED" == "false" ]]; then | |
echo "Firely Terminal is up-to-date. Skip creating a PR." | |
exit 0 | |
fi | |
BRANCH_NAME="update-firely-terminal-version-$LATEST_RELEASE" | |
REMOTE_REPO="https://github.com/FirelyTeam/firely-terminal-pipeline.git" | |
if git ls-remote --heads "$REMOTE_REPO" "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then | |
echo "Branch '$BRANCH_NAME' already exists. Skipping creation of PR." | |
exit 0 | |
fi | |
git checkout -b "$BRANCH_NAME" | |
sed -i "/FIRELY_TERMINAL_VERSION:/,/default:/s/\(default: \).*/\1'$LATEST_RELEASE'/" action.yml | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git add action.yml | |
git commit -m "Update FIRELY_TERMINAL_VERSION to $LATEST_RELEASE" | |
git push -u origin "$BRANCH_NAME" | |
gh pr create --base main --head "$BRANCH_NAME" --title "Update FIRELY_TERMINAL_VERSION to $LATEST_RELEASE" --body "This PR updates the FIRELY_TERMINAL_VERSION to $LATEST_RELEASE." | |
env: | |
GH_TOKEN: ${{ github.token }} |