Skip to content

Update edge image #2610

Update edge image

Update edge image #2610

name: Update edge image
on:
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- name: Fetch release version
id: fetch-release
run: |
export NUT_COMMIT_REF=$(curl -sL https://api.github.com/repos/blawar/NUT/commits/master | jq -r '.sha')
export NUT_COMMIT_REF_SHORT=${NUT_COMMIT_REF:0:7}
if [ -n "$NUT_COMMIT_REF" ] && [ "$NUT_COMMIT_REF" != "null" ]; then
echo "Updated APP_VERSION with $NUT_COMMIT_REF_SHORT in .github/workflows/docker-publish.yml"
sed -ri "s/^(\s*)(APP_VERSION\s*:\s*.*\s*$)/\1APP_VERSION: \"$NUT_COMMIT_REF_SHORT\"/" .github/workflows/docker-publish.yml
sed -ri "s/^(\s*)(COMMIT_REF\s*:\s*.*\s*$)/\1COMMIT_REF: \"$NUT_COMMIT_REF\"/" .github/workflows/docker-publish.yml
sed -ri "s/^(\s*)(COMMIT_REF_SHORT\s*:\s*.*\s*$)/\1COMMIT_REF_SHORT: \"$NUT_COMMIT_REF_SHORT\"/" .github/workflows/docker-publish.yml
echo "version=${NUT_COMMIT_REF_SHORT}" >> $GITHUB_OUTPUT
fi
- name: Check for modified files
id: git-check
run: echo modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") >> $GITHUB_OUTPUT
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .github/workflows/docker-publish.yml
git commit -m "ci(docker-publish): update nut ref to ${{ steps.fetch-release.outputs.version }}"
git push