Discover new software releases #627
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: Discover new software releases | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- .github/workflows/discover-releases.yml | |
schedule: | |
- cron: '0 20 * * *' | |
jobs: | |
update-releases: | |
timeout-minutes: 5 | |
runs-on: ubuntu-20.04 | |
steps: | |
# have to checkout with token in order to push later | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
- name: Fetch software releases | |
shell: bash | |
run: | | |
set -ueo pipefail | |
CURL_OPTIONS="--silent \ | |
--location \ | |
--connect-timeout 5 \ | |
--max-time 10 \ | |
--retry 5 \ | |
--retry-delay 0 \ | |
--retry-max-time 40 \ | |
" | |
URLS=( \ | |
http://downloads.asterisk.org/pub/telephony/asterisk/releases/ \ | |
http://downloads.asterisk.org/pub/telephony/asterisk/ \ | |
http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/ \ | |
) | |
ASTERISK_RELEASES="" | |
for URL in "${URLS[@]}"; do | |
_ASTERISK_RELEASES="$( \ | |
curl $CURL_OPTIONS $URL \ | |
| grep '<a href="asterisk.*.tar.gz">' \ | |
| grep -v '\-patch\|\-addons\|\-sounds' \ | |
| awk -F '</td><td>|">asterisk' '{print $2}' \ | |
| awk -F '"' '{print $NF}' \ | |
| awk -F 'asterisk-' '{print $NF}' \ | |
| awk -F '.tar.gz' '{print $1}' \ | |
)" | |
ASTERISK_RELEASES+="${_ASTERISK_RELEASES}\n" | |
done | |
ASTERISK_RELEASES="$( \ | |
echo -en "${ASTERISK_RELEASES}" \ | |
| sort --unique \ | |
| sort --field-separator='.' --key=1,1n --key=2,2n --key=3,3n --key=4,4n \ | |
)" | |
echo -en "${ASTERISK_RELEASES}" > ./asterisk-releases.txt | |
URLS=( \ | |
http://downloads.asterisk.org/pub/telephony/certified-asterisk/ \ | |
http://downloads.asterisk.org/pub/telephony/certified-asterisk/releases/ \ | |
) | |
ASTERISK_RELEASES="" | |
for URL in "${URLS[@]}"; do | |
_ASTERISK_RELEASES="$( \ | |
curl $CURL_OPTIONS $URL \ | |
| grep '<a href="asterisk.*.tar.gz">' \ | |
| grep -v '\-patch\|\-addons\|\-sounds' \ | |
| awk -F '</td><td>|">asterisk' '{print $2}' \ | |
| awk -F '"' '{print $NF}' \ | |
| awk -F 'asterisk-' '{print $NF}' \ | |
| awk -F '.tar.gz' '{print $1}' \ | |
)" | |
ASTERISK_RELEASES+="${_ASTERISK_RELEASES}\n" | |
done | |
ASTERISK_CERTIFIED_RELEASES="$( \ | |
echo -en "${ASTERISK_RELEASES}" \ | |
| sort --unique \ | |
| sort --field-separator='t' --key=2,1n \ | |
| sort --stable --field-separator='.' --key=1,1n --key=2,2n | |
)" | |
echo -en "${ASTERISK_CERTIFIED_RELEASES}" > ./asterisk-certified-releases.txt | |
TOKEN_URI="https://auth.docker.io/token" | |
LIST_URI="https://registry-1.docker.io/v2/###IMAGE###/tags/list" | |
IMAGE='library/alpine' | |
IMAGE_GLIBC='frolvlad/alpine-glibc' | |
SCOPE="scope=repository:${IMAGE}:pull&scope=repository:${IMAGE_GLIBC}:pull&" | |
TOKEN=$(curl -Ss "${TOKEN_URI}?service=registry.docker.io&${SCOPE}" | jq -r .token) | |
( | |
THIS_URI=$(echo -n "${LIST_URI}" | sed -e "s^###IMAGE###^${IMAGE}^") | |
curl -SsL \ | |
-H "Accept: application/json" \ | |
-H "Authorization: Bearer $TOKEN" "${THIS_URI}" \ | |
| jq -M -r '.tags[]' \ | |
| grep -P '^[3]\.\d+$' \ | |
| sort \ | |
| sort --stable --field-separator='.' --key=1,1n --key=2,2n | |
echo "latest" | |
echo "edge" | |
) \ | |
| sed -re "s/^/alpine:/g" \ | |
> ./docker-alpine-tags.txt | |
( | |
THIS_URI=$(echo -n "${LIST_URI}" | sed -e "s^###IMAGE###^${IMAGE_GLIBC}^") | |
curl -Ss \ | |
-H "Accept: application/json" \ | |
-H "Authorization: Bearer $TOKEN" "${THIS_URI}" \ | |
| jq -M -r '.tags[]' \ | |
| grep -P '^alpine-[3]\.\d+$' \ | |
| sort --stable --field-separator='-' --key=1,1n \ | |
| sort --stable --field-separator='.' --key=1,1n --key=2,2n | |
echo "latest" | |
echo "edge" | |
) \ | |
| sed -re "s/^/frolvlad\/alpine-glibc:/g" \ | |
> ./docker-alpine-glibc-tags.txt | |
- name: Commit and push updates | |
shell: bash | |
run: | | |
set -ueo pipefail | |
if [ "$(git status -s)" != "" ]; then | |
git config user.email "[email protected]" | |
git config user.name "github-actions[bot]" | |
git add ./asterisk-releases.txt | |
git add ./asterisk-certified-releases.txt | |
git add ./docker-alpine-tags.txt | |
git add ./docker-alpine-glibc-tags.txt | |
git commit \ | |
--all \ | |
--message "[$(date '+%Y-%m-%d %H:%M')] automatic update of release lists" | |
git push | |
else | |
echo "Nothing to push, no updates" | |
fi |