Update .forgejo/workflows/package-check.yml
This commit is contained in:
parent
cdf0201bd4
commit
9dac56f9cd
1 changed files with 23 additions and 21 deletions
|
@ -31,27 +31,27 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get latest package version
|
- name: Get latest package version
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
main_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz \
|
main_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz \
|
||||||
| tar -xzO \
|
| tar -xzO \
|
||||||
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
||||||
| sort -V | tail -n1)
|
| sort -V | tail -n 1)
|
||||||
|
|
||||||
community_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz \
|
community_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz \
|
||||||
| tar -xzO \
|
| tar -xzO \
|
||||||
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
||||||
| sort -V | tail -n1)
|
| sort -V | tail -n 1)
|
||||||
|
|
||||||
testing_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz \
|
testing_version=$(curl -s https://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz \
|
||||||
| tar -xzO \
|
| tar -xzO \
|
||||||
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
| awk '$0=="P:rsync" { getline; if ($0 ~ /^V:/) print substr($0,3) }' \
|
||||||
| sort -V | tail -n1)
|
| sort -V | tail -n 1)
|
||||||
|
|
||||||
newest_version=$(echo -e "$main_version\n$community_version\n$testing_version" | sort -V | tail -n1)
|
newest_version=$(echo -e "$main_version\n$community_version\n$testing_version" | sort -V | tail -n 1)
|
||||||
|
|
||||||
echo "NEWEST_VERSION=$newest_version" >> $GITHUB_ENV
|
echo "NEWEST_VERSION=$newest_version" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Determine if update is needed
|
- name: Determine if update is needed
|
||||||
run: |
|
run: |
|
||||||
|
@ -62,7 +62,7 @@ jobs:
|
||||||
last_version=$(cat $last_version_file 2>/dev/null || echo "none")
|
last_version=$(cat $last_version_file 2>/dev/null || echo "none")
|
||||||
last_rebuild=$(cat $last_rebuild_file 2>/dev/null || echo 0)
|
last_rebuild=$(cat $last_rebuild_file 2>/dev/null || echo 0)
|
||||||
last_dockerfile_hash=$(cat $last_dockerfile_hash_file 2>/dev/null || echo "none")
|
last_dockerfile_hash=$(cat $last_dockerfile_hash_file 2>/dev/null || echo "none")
|
||||||
dockerfile_hash=$(sha256sum Dockerfile 2>/dev/null || echo "nuh")
|
dockerfile_hash=$(sha256sum Dockerfile 2>/dev/null | awk '{print $1}' || echo "nuh")
|
||||||
current_day=$(( $(date +%s) / 86400 ))
|
current_day=$(( $(date +%s) / 86400 ))
|
||||||
|
|
||||||
update="false"
|
update="false"
|
||||||
|
@ -86,18 +86,20 @@ jobs:
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
if: env.UPDATE == 'true'
|
if: env.UPDATE == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build -t $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:latest -t $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:$LATEST_VERSION .
|
docker build -t $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:latest -t $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:$NEWEST_VERSION .
|
||||||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login $DOCKER_REGISTRY -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login $DOCKER_REGISTRY -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||||
docker push $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:latest
|
docker push $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:latest
|
||||||
docker push $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:$LATEST_VERSION
|
docker push $DOCKER_REGISTRY/$REGISTRY_USER/docker-$PACKAGE:$NEWEST_VERSION
|
||||||
echo "$NEWEST_VERSION" > .last_version
|
echo "$NEWEST_VERSION" > .last_version
|
||||||
echo $(( $(date +%s) / 86400 )) > .last_rebuild
|
echo $(( $(date +%s) / 86400 )) > .last_rebuild
|
||||||
|
dockerfile_hash=$(sha256sum Dockerfile | awk '{print $1}')
|
||||||
|
echo "$dockerfile_hash" > .dockerfile_hash
|
||||||
|
|
||||||
- name: Commit updated metadata
|
- name: Commit updated metadata
|
||||||
if: env.UPDATE == 'true'
|
if: env.UPDATE == 'true'
|
||||||
run: |
|
run: |
|
||||||
git config user.name "$COMMIT_AUTHOR_NAME"
|
git config user.name "$COMMIT_AUTHOR_NAME"
|
||||||
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||||
git add .last_version .last_rebuild
|
git add .last_version .last_rebuild .dockerfile_hash
|
||||||
git commit -m "$COMMIT_MESSAGE"
|
git commit -m "$COMMIT_MESSAGE"
|
||||||
git push
|
git push
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue