Files
ansible_role_scm/.gitea/workflows/update-gitea-version.yml
Luciano Giacchetta 987d2ec610
Some checks failed
Update Gitea Version / update-version (pull_request) Failing after 3m11s
Testing Molecule
2026-04-08 18:59:56 -03:00

82 lines
3.1 KiB
YAML

#SPDX-License-Identifier: GPL-3.0-only
---
name: Update Gitea Version
on:
schedule:
- cron: '0 6 * * *' # Every day at 06:00 UTC
workflow_dispatch:
pull_request:
branches:
- main
jobs:
update-version:
runs-on: fedora-latest
steps:
- name: Add ~/.local/bin to PATH
run: echo "$HOME/.local/bin" >> "$GITEA_PATH"
- name: Checkout
uses: actions/checkout@v6
with:
path: ansible_role_scm
- name: Check versions
id: check
working-directory: ansible_role_scm
run: |
LATEST=$(curl -sf https://api.github.com/repos/go-gitea/gitea/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if ! [[ "$LATEST" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Refusing to bump to non-stable version '$LATEST'"
exit 1
fi
CURRENT=$(grep "^gitea_version:" defaults/main.yml | sed "s/gitea_version: '//;s/'//")
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
if [ "$LATEST" = "$CURRENT" ]; then
echo "needs_update=false" >> "$GITHUB_OUTPUT"
echo "Already on latest: $CURRENT"
else
echo "needs_update=true" >> "$GITHUB_OUTPUT"
echo "Update available: $CURRENT -> $LATEST"
fi
- name: Install Molecule
# if: steps.check.outputs.needs_update == 'true'
run: pip install ansible molecule molecule-plugins[podman]
- name: Install Ansible collections
# if: steps.check.outputs.needs_update == 'true'
run: ansible-galaxy collection install containers.podman
- name: Update gitea_version
if: steps.check.outputs.needs_update == 'true'
working-directory: ansible_role_scm
run: |
sed -i "s/^gitea_version: '.*'$/gitea_version: '${{ steps.check.outputs.latest }}'/" defaults/main.yml
UPDATED=$(grep "^gitea_version:" defaults/main.yml | sed "s/gitea_version: '//;s/'//")
if [ "$UPDATED" != "${{ steps.check.outputs.latest }}" ]; then
echo "::error::Failed to update gitea_version (expected '${{ steps.check.outputs.latest }}', got '$UPDATED')"
exit 1
fi
echo "Verified: gitea_version updated to $UPDATED"
- name: Run Molecule tests
# if: steps.check.outputs.needs_update == 'true'
working-directory: ansible_role_scm
run: molecule test
- name: Commit and push
if: steps.check.outputs.needs_update == 'true' && github.ref == 'refs/heads/main'
working-directory: ansible_role_scm
run: |
git config user.name "giabot"
git config user.email "bot@mail.gianet.us"
git remote set-url origin "https://giabot:${{ secrets.GITEA_TOKEN }}@gianet.us/engineering/ansible_role_scm.git"
git add defaults/main.yml
git commit -m "patch: update gitea_version to ${{ steps.check.outputs.latest }}"
git tag "${{ steps.check.outputs.latest }}"
git tag -f latest
git push origin main "${{ steps.check.outputs.latest }}"
git push -f origin latest