Improve GitHub Action to not fail if no update is needed
This commit is contained in:
parent
a3e8f0f6c4
commit
d16f07529a
19
.github/workflows/updater.yml
vendored
19
.github/workflows/updater.yml
vendored
|
@ -36,31 +36,37 @@ jobs:
|
||||||
echo "VERSION=$version" >> $GITHUB_ENV
|
echo "VERSION=$version" >> $GITHUB_ENV
|
||||||
echo "ASSETS=$assets" >> $GITHUB_ENV
|
echo "ASSETS=$assets" >> $GITHUB_ENV
|
||||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
||||||
echo ::set-output name=to_update::false
|
echo "PROCEED=false" >> $GITHUB_ENV
|
||||||
echo "::warning ::No new version available"
|
echo "::warning ::No new version available"
|
||||||
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
||||||
echo ::set-output name=to_update::false
|
echo "PROCEED=false" >> $GITHUB_ENV
|
||||||
echo "::warning ::A branch already exists for that"
|
echo "::warning ::A branch already exists for this update"
|
||||||
else
|
else
|
||||||
echo ::set-output name=to_update::true
|
echo "PROCEED=true" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
- name: Update package files
|
- name: Update package files
|
||||||
id: update_files
|
id: update_files
|
||||||
if: steps.check_version.outputs.to_update == 'true'
|
if: ${{ env.PROCEED == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
# Setting up Git user
|
# Setting up Git user
|
||||||
git config --global user.name 'yunohost-bot'
|
git config --global user.name 'yunohost-bot'
|
||||||
git config --global user.email 'yunohost-bot@users.noreply.github.com'
|
git config --global user.email 'yunohost-bot@users.noreply.github.com'
|
||||||
# Run the version updater script
|
# Run the version updater script
|
||||||
./.github/workflows/updater.sh
|
./.github/workflows/updater.sh
|
||||||
|
retval=$?
|
||||||
|
# Check
|
||||||
|
if [ $retval -neq 0 ]; then
|
||||||
|
echo "PROCEED=false" >> $GITHUB_ENV
|
||||||
|
echo "::warning ::The updater script failed (exit code $retval)"
|
||||||
|
fi
|
||||||
# Replace new version in manifest
|
# Replace new version in manifest
|
||||||
jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json
|
jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json
|
||||||
# Commit
|
# Commit
|
||||||
git commit -am "Upgrade to v$VERSION"
|
git commit -am "Upgrade to v$VERSION"
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr
|
id: cpr
|
||||||
|
if: ${{ env.PROCEED == 'true' }}
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v3
|
||||||
if: steps.check_version.outputs.to_update == 'true'
|
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
commit-message: Update to version ${{ env.VERSION }}
|
commit-message: Update to version ${{ env.VERSION }}
|
||||||
|
@ -74,6 +80,7 @@ jobs:
|
||||||
Upgrade to v${{ env.VERSION }}
|
Upgrade to v${{ env.VERSION }}
|
||||||
draft: false
|
draft: false
|
||||||
- name: Check outputs
|
- name: Check outputs
|
||||||
|
if: ${{ env.PROCEED == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user