Skip to content

Commit

Permalink
build: Fetch tag
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Nov 14, 2023
1 parent d33b926 commit faa753c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,33 @@ jobs:
packages: write
contents: read
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Get remote package data
run: |
#!/bin/bash
curl --show-error --fail --silent "https://pkgs.alpinelinux.org/package/edge/community/aarch64/munin" --output ./package_data.html
latest_tag=$(grep -A 3 -i version ./package_data.html | sed -E 's#.*>([0-9\.]+)-r[0-9]+</a>#\1#g' | tail -1 | sed 's/^[ \t]*//;s/[ \t]*$//')
[ -z "$latest_tag" ] && echo "Tag not found!" && exit 1
[[ "$latest_tag" = v* ]] && latest_tag="${latest_tag:1}"
echo "Found tag: \"${latest_tag}\""
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
-
name: Check if the new tag exists in DockerHub
name: Check if the tag exists in DockerHub
id: check-tag
run: |
#!/bin/bash
dockerhub_tags=$(curl -s https://hub.docker.com/v2/repositories/${{ secrets.DOCKERHUB_REPO }}/tags | jq -r '.results[].name')
if echo "${dockerhub_tags}" | grep -q "${{ env.latest_tag }}"; then
if echo "${dockerhub_tags}" | grep -qx "${{ env.latest_tag }}"; then
echo "exists=true" >> $GITHUB_ENV
else
echo "exists=false" >> $GITHUB_ENV
fi
-
name: Checkout
if: env.exists == 'false'
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Docker Buildx
if: env.exists == 'false'
Expand Down

0 comments on commit faa753c

Please sign in to comment.