GitLab Release Checker #11
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: Sync Docker Hub GitLab Versions | |
# Ensure Proper Permissions for the Workflow Token | |
permissions: | |
contents: write | |
actions: write | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: '30 4 * * *' | |
jobs: | |
check-new-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get recent Tags from Docker Hub for ce and ee | |
id: fetch-tags | |
run: | | |
# Fetch both ce and ee tags | |
curl -s "https://hub.docker.com/v2/namespaces/gitlab/repositories/gitlab-ce/tags?page_size=100" | jq -r '.results[].name' > dockerhub_tags_ce.txt | |
curl -s "https://hub.docker.com/v2/namespaces/gitlab/repositories/gitlab-ee/tags?page_size=100" | jq -r '.results[].name' > dockerhub_tags_ee.txt | |
# Combine both ce and ee tags | |
cat dockerhub_tags_ce.txt dockerhub_tags_ee.txt > dockerhub_tags.txt | |
- name: Find latest ce and ee tags | |
id: find-latest-tags | |
run: | | |
# Find latest ce tag | |
sort -V dockerhub_tags_ce.txt | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-ce\.0$' | tail -n 1 > latest_ce_tag.txt | |
LATEST_CE_TAG=$(cat latest_ce_tag.txt) | |
echo "latest_ce_tag=$LATEST_CE_TAG" >> $GITHUB_OUTPUT | |
# Find latest ee tag | |
sort -V dockerhub_tags_ee.txt | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-ee\.0$' | tail -n 1 > latest_ee_tag.txt | |
LATEST_EE_TAG=$(cat latest_ee_tag.txt) | |
echo "latest_ee_tag=$LATEST_EE_TAG" >> $GITHUB_OUTPUT | |
- name: Check if ce tag exists on Docker Hub | |
id: check-existing-ce | |
run: | | |
TAG="${{ steps.find-latest-tags.outputs.latest_ce_tag }}" | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "https://hub.docker.com/v2/repositories/feskol/gitlab/tags/${TAG}") | |
if [ "$RESPONSE" -eq 200 ]; then | |
echo "Tag $TAG exists on Docker Hub (ce)." | |
echo "update_required_ce=false" >> $GITHUB_OUTPUT | |
else | |
echo "Tag $TAG does not exist on Docker Hub (ce)." | |
echo "update_required_ce=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Check if ee tag exists on Docker Hub | |
id: check-existing-ee | |
run: | | |
TAG="${{ steps.find-latest-tags.outputs.latest_ee_tag }}" | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "https://hub.docker.com/v2/repositories/feskol/gitlab/tags/${TAG}") | |
if [ "$RESPONSE" -eq 200 ]; then | |
echo "Tag $TAG exists on Docker Hub (ee)." | |
echo "update_required_ee=false" >> $GITHUB_OUTPUT | |
else | |
echo "Tag $TAG does not exist on Docker Hub (ee)." | |
echo "update_required_ee=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Trigger build.yml for ce release | |
if: steps.check-existing-ce.outputs.update_required_ce == 'true' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: "build.yml", | |
ref: "main", | |
inputs: { | |
gitlab_release: "${{ steps.find-latest-tags.outputs.latest_ce_tag }}" | |
} | |
}) | |
- name: Trigger build.yml for ee release | |
if: steps.check-existing-ee.outputs.update_required_ee == 'true' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: "build.yml", | |
ref: "main", | |
inputs: { | |
gitlab_release: "${{ steps.find-latest-tags.outputs.latest_ee_tag }}" | |
} | |
}) |