Auto-update #182
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: "Auto-update" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 8 * * 6' | |
jobs: | |
auto_update: | |
name: "Auto-update" | |
runs-on: "ubuntu-22.04" | |
steps: | |
- name: "Checkout project sources" | |
uses: "actions/checkout@v3" | |
with: | |
token: "${{ secrets.RELEASE_PAT }}" | |
ref: "${{ github.head_ref }}" | |
path: "src" | |
- name: "Configure Git identity" | |
run: | | |
set -e | |
cd src/ | |
git config --global user.name "bigbrozer" | |
git config --global user.email "<bigbrozer@users.noreply.github.com>" | |
- name: "Checkout TT-RSS sources" | |
run: | | |
set -e | |
git clone --branch=master https://git.tt-rss.org/fox/tt-rss.git ttrss | |
- name: "Get version details" | |
id: "versions" | |
run: | | |
set -e | |
ttrss_commit_now="$(awk 'match($0,/^ARG TTRSS_COMMIT="(.*)"/,m) {print m[1]}' src/Dockerfile)" | |
ttrss_commit_last="$(cd ttrss && git rev-parse --short=7 HEAD)" | |
echo "ttrss_commit_now=${ttrss_commit_now}" >> $GITHUB_OUTPUT | |
echo "ttrss_commit_last=${ttrss_commit_last}" >> $GITHUB_OUTPUT | |
echo "Set pipeline variable: ttrss_commit_now=${ttrss_commit_now}" | |
echo "Set pipeline variable: ttrss_commit_last=${ttrss_commit_last}" | |
- name: "Changes for TT-RSS" | |
id: "changes" | |
run: | | |
set -e | |
tag_name="$(date +"v%Y.%m.%d")" | |
ttrss_changes="$(cd ttrss && git log --no-patch --oneline --format='* %s' ${{ steps.versions.outputs.ttrss_commit_now }}..${{ steps.versions.outputs.ttrss_commit_last }})" | |
echo "ttrss_tag_name=${tag_name}" >> $GITHUB_OUTPUT | |
if [[ -n "${ttrss_changes}" ]] | |
then | |
echo -ne "## Upstream changes\n\n" | tee "/tmp/ttrss_changes.md" | |
echo "${ttrss_changes}" | tee -a "/tmp/ttrss_changes.md" | |
echo "ttrss_has_changes=yes" >> $GITHUB_OUTPUT | |
else | |
echo "No change. Up to date." | |
echo "ttrss_has_changes=no" >> $GITHUB_OUTPUT | |
fi | |
- name: "Update version" | |
if: ${{ success() && steps.changes.outputs.ttrss_has_changes == 'yes' }} | |
run: | | |
set -e | |
cd src/ | |
sed -i -r \ | |
-e "s#^ARG TTRSS_COMMIT=\".*\"#ARG TTRSS_COMMIT=\"${{ steps.versions.outputs.ttrss_commit_last }}\"#g" \ | |
Dockerfile | |
- name: "Commits" | |
if: ${{ success() && steps.changes.outputs.ttrss_has_changes == 'yes' }} | |
uses: "stefanzweifel/git-auto-commit-action@v4" | |
with: | |
repository: "src" | |
commit_message: "feat(ttrss): bump ttrss version to commit ${{ steps.versions.outputs.ttrss_commit_last }}" | |
tagging_message: "${{ steps.changes.outputs.ttrss_tag_name }}" | |
push_options: '--follow-tags' | |
- name: "Create auto release" | |
if: ${{ success() && steps.changes.outputs.ttrss_has_changes == 'yes' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.RELEASE_PAT }} | |
bodyFile: "/tmp/ttrss_changes.md" | |
tag: "${{ steps.changes.outputs.ttrss_tag_name }}" | |
- name: "Manual tag version" | |
if: ${{ success() && github.event_name == 'workflow_dispatch' && steps.changes.outputs.ttrss_has_changes == 'no' }} | |
run: | | |
set -e | |
cd src/ | |
git tag -a -m "Manual release" "${{ steps.changes.outputs.ttrss_tag_name }}" | |
git push --follow-tags | |
- name: "Create manual release" | |
if: ${{ success() && github.event_name == 'workflow_dispatch' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.RELEASE_PAT }} | |
generateReleaseNotes: true | |
tag: "${{ steps.changes.outputs.ttrss_tag_name }}" |