Check for updates #422
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: Check for updates | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- main | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.ref }}' | |
cancel-in-progress: false | |
jobs: | |
update: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup GPG | |
id: import-gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
git_config_global: true | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Install yq | |
run: | | |
mkdir -p $HOME/.bin | |
curl -s https://api.github.com/repos/mikefarah/yq/releases/latest \ | |
| grep "browser_download_url.*yq_linux_amd64\"" \ | |
| cut -d : -f 2,3 | tr -d \" \ | |
| wget -qi - -O $HOME/.bin/yq | |
chmod +x $HOME/.bin/yq | |
echo "$HOME/.bin" >> $GITHUB_PATH | |
- name: Check for updates | |
run: | | |
bash ./update.sh | |
- name: Check if there are any changes | |
id: check-changes | |
run: | | |
# Check git status --porcelain | |
if [[ -z $(git status --porcelain) ]]; then | |
echo "No changes detected" | |
echo "CHANGES=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected" | |
echo "CHANGES=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit changes | |
if: steps.check-changes.outputs.CHANGES == 'true' | |
run: | | |
git add -A | |
git commit --signoff -m "Update Flatpak dependencies" | |
env: | |
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }} | |
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }} | |
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }} | |
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
id: cpr | |
if: steps.check-changes.outputs.CHANGES == 'true' | |
with: | |
token: ${{ secrets.PAT }} | |
branch: automated/flatpak-update | |
delete-branch: true | |
title: Update Flatpak dependencies | |
body: Automated update to Flatpak dependencies | |
labels: | | |
update | |
chore | |
automated pr | |
autorebase:opt-in | |
- name: Automerge Pull Request | |
if: steps.check-changes.outputs.CHANGES && 'true' && (steps.cpr.outputs.pull-request-operation == 'created' || steps.cpr.outputs.pull-request-operation == 'updated') | |
run: gh pr merge --rebase --auto "$PR_NUMBER" | |
env: | |
GH_TOKEN: ${{ secrets.PAT }} | |
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }} |