Skip to content

Check For Latest Versions #2645

Check For Latest Versions

Check For Latest Versions #2645

name: Check For Latest Versions
on:
schedule:
- cron: '0 0 * * *'
env:
NEW_BRANCH: bump-versions-${{ github.run_id }}
jobs:
check-version:
runs-on: ubuntu-20.04
steps:
- name: Checkout Packer Project
uses: actions/checkout@v4
- name: Compare versions
id: compare-versions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_COMMIT_MESSAGE: Continuous Integration Commit Artifacts
CI_COMMIT_AUTHOR: Continuous Integration
run: |
current_version=$(cat versions.json | jq -r '.runner')
latest_version=$(gh api /repos/actions/runner/releases/latest | jq -r .tag_name)
if [ "$current_version" = "$latest_version" ]; then
matching=true;
else
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "[email protected]"
git checkout -b $NEW_BRANCH
cat versions.json | jq --arg v "$latest_version" '.runner = ($v)' > tmp.json
cat tmp.json > versions.json
rm tmp.json
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
git push origin $NEW_BRANCH
matching=false
fi
echo "::set-output name=matching::$matching"
- name: Create PR
if: ${{ steps.compare-versions.outputs.matching == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr create --title "[bot] Bump versions" --body "Versions bumped" -B develop -H $NEW_BRANCH