Update Chocolatey packages #72
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: Update Chocolatey packages | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: "Package to update" | |
required: true | |
type: choice | |
options: | |
- all | |
- git-sumi | |
- shuku | |
- zola | |
schedule: | |
- cron: "52 3 * * *" # Run at 03:52 AM UTC daily | |
env: | |
BRANCH_PREFIX: feat/update | |
jobs: | |
update-packages: | |
name: Update packages | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
contents: write | |
pull-requests: write | |
strategy: | |
matrix: | |
package: ${{ github.event_name == 'schedule' && fromJson('["git-sumi", "shuku", "zola"]') || fromJson(format('["{0}"]', github.event.inputs.package)) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq curl git libxml2-utils | |
- name: Configure GPG key | |
run: | | |
echo -n ${{ secrets.GPG_PRIVATE_KEY }} | base64 --decode | gpg --import | |
- name: Configure Git | |
run: | | |
git config --global user.signingkey D3C944915B1A7B6B66553B20C50DCAE3B60ED3AC | |
git config --global commit.gpgsign true | |
git config --global user.name "welpo" | |
git config --global user.email "[email protected]" | |
- name: Create and switch to new branch | |
run: | | |
timestamp=$(date +%Y%m%d-%H%M%S) | |
branch_name="${{ env.BRANCH_PREFIX }}-${{ matrix.package }}-${timestamp}" | |
echo "BRANCH_NAME=${branch_name}" >> $GITHUB_ENV | |
git checkout -b ${branch_name} | |
- name: Run update script | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
chmod +x scripts/update-packages | |
if [[ "${{ matrix.package }}" == "all" ]]; then | |
./scripts/update-packages all | |
else | |
./scripts/update-packages --${{ matrix.package }} | |
fi | |
- name: Push changes and create PR | |
run: | | |
if git diff --quiet HEAD origin/main; then | |
echo "No changes to push for ${{ matrix.package }}" | |
exit 0 | |
fi | |
git push -u origin ${BRANCH_NAME} | |
gh pr create --fill \ | |
--base main \ | |
--head ${BRANCH_NAME} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |