Update .forgejo/workflows/package-check.yml
This commit is contained in:
parent
4f47259b53
commit
0996a098fb
1 changed files with 17 additions and 12 deletions
|
@ -20,25 +20,29 @@ jobs:
|
|||
|
||||
- name: Check for latest package version
|
||||
id: check
|
||||
shell: sh
|
||||
run: |
|
||||
PACKAGE="curl"
|
||||
LATEST=$(apk policy $PACKAGE | sed -n '2p' | sed 's/^[[:space:]]*//; s/[[:space:]:]*$//')
|
||||
echo "latest_version=$LATEST" >> "$GITHUB_OUTPUT"
|
||||
LATEST=$(apk policy "$PACKAGE" | sed -n '2p' | sed 's/^[[:space:]]*//; s/[[:space:]:]*$//')
|
||||
echo "LATEST_VERSION=$LATEST" >> $GITHUB_ENV
|
||||
echo "latest_version=$LATEST" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Compare with last known version
|
||||
id: compare
|
||||
shell: sh
|
||||
run: |
|
||||
FILE=".last_version"
|
||||
[ -f "$FILE" ] && LAST=$(cat "$FILE") || LAST="none"
|
||||
echo "Last known version: $LAST"
|
||||
if [ "$LAST" != "${{ steps.check.outputs.latest_version }}" ]; then
|
||||
echo "update=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Current version: $LATEST_VERSION"
|
||||
if [ "$LAST" != "$LATEST_VERSION" ]; then
|
||||
echo "UPDATE=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "update=false" >> "$GITHUB_OUTPUT"
|
||||
echo "UPDATE=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Start dockerd
|
||||
if: steps.compare.outputs.update == 'true'
|
||||
if: env.UPDATE == 'true'
|
||||
shell: sh
|
||||
run: |
|
||||
dockerd-entrypoint.sh &
|
||||
timeout=30
|
||||
|
@ -53,19 +57,20 @@ jobs:
|
|||
done
|
||||
|
||||
- name: Build and push Docker image
|
||||
if: steps.compare.outputs.update == 'true'
|
||||
if: env.UPDATE == 'true'
|
||||
shell: sh
|
||||
run: |
|
||||
docker build -t git.shork.ch/melody/docker-test:latest .
|
||||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.shork.ch -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
docker push git.shork.ch/melody/docker-test:latest
|
||||
echo "${{ steps.check.outputs.latest_version }}" > .last_version
|
||||
echo "$LATEST_VERSION" > .last_version
|
||||
|
||||
- name: Commit updated version file
|
||||
if: steps.compare.outputs.update == 'true'
|
||||
if: env.UPDATE == 'true'
|
||||
shell: sh
|
||||
run: |
|
||||
git config user.name "forgejo-runner"
|
||||
git config user.email "runner@forgejo.local"
|
||||
git add .last_version
|
||||
git commit -m "Update tracked version to ${{ steps.check.outputs.latest_version }}"
|
||||
git commit -m "Update tracked version to $LATEST_VERSION"
|
||||
git push
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue