From 9a91de298b3eb880d2146a0776f17f60f2ee8d87 Mon Sep 17 00:00:00 2001 From: Ryan Borstelmann Date: Sat, 14 Sep 2024 14:43:35 -0500 Subject: [PATCH 1/2] Removing deprecated caddyBuilder.ps1 --- .github/workflows/caddyBuilder.ps1 | 71 ------------------------------ 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/caddyBuilder.ps1 diff --git a/.github/workflows/caddyBuilder.ps1 b/.github/workflows/caddyBuilder.ps1 deleted file mode 100644 index 07c6717..0000000 --- a/.github/workflows/caddyBuilder.ps1 +++ /dev/null @@ -1,71 +0,0 @@ -$containers = @( -"library/caddy" # Main caddy container -"slothcroissant/caddy-cloudflaredns" # Custom caddy container -) - -$imageVersions = @{} -foreach ($container in $containers) -{ - Write-Output "Calling Docker Hub to get $container Versions..." - $request = Invoke-RestMethod -Method GET -Uri "https://hub.docker.com/v2/repositories/$container/tags" - $imageVersions[$container] = $request.results.name -match '^\d+\.\d+\.\d+$' - while ($request.next) - { - Write-Output " ... requesting page $(($request.next -split 'page=')[-1])" - $request = Invoke-RestMethod -Method GET -Uri $request.next - $imageVersions[$container] += $request.results.name -match '^\d+\.\d+\.\d+$' - } - - Write-Output "Found the following $container Versions:" - Write-Output $imageVersions[$container] -} - -$latestOfficialVersion = $imageVersions["library/caddy"][0] -$latestSlothcrossantVersion = $imageVersions["slothcroissant/caddy-cloudflaredns"][0] - -Write-Output "Latest Offical version: $latestOfficialVersion" -Write-Output "Latest Slothcroissant version: $latestSlothcrossantVersion" - -if ($imageVersions["library/caddy"].IndexOf($imageVersions["slothcroissant/caddy-cloudflaredns"][0]) -gt 0) -{ - Write-Output "Docker image slothcroissant/caddy-cloudflaredns:$($imageVersions[`"slothcroissant/caddy-cloudflaredns`"][0]) is $($imageVersions["library/caddy"].IndexOf($imageVersions["slothcroissant/caddy-cloudflaredns"][0])) version behind image library/caddy:$($imageVersions[`"library/caddy`"][0])" - $regexStrings = Get-Content .\Dockerfile | Select-String '\d+\.\d+\.\d+' -AllMatches - - foreach ($string in $regexStrings) - { - Write-Output " Processing line: `"$string`"" - $oldString = $string.tostring() - $newString = $oldString.replace($imageVersions["slothcroissant/caddy-cloudflaredns"][0],$latestOfficialVersion) - Write-Output " New line: `"$newString`"" - (Get-Content .\Dockerfile).Replace($oldString,$newString) | Set-Content .\Dockerfile - } -} -else -{ - Write-Output "Docker image slothcroissant/caddy-cloudflaredns:$($imageVersions[`"slothcroissant/caddy-cloudflaredns`"][0]) matches image library/caddy:$($imageVersions[`"library/caddy`"][0])" -} - - -Write-Output "" -Write-Output "***************************************" -Write-Output "Performing Git Operations..." -git config user.email "ryan@ryanb.tv" -git config user.name "SlothCroissant" -Write-Output "Staging all changed files..." -git add . -if (git diff HEAD) -{ - Write-Output "Committing changes..." - git commit -m "GitHub Actions commit: Updated caddy to $($latestOfficialVersion) [skip ci]" - Write-Output "Applying git tag $($latestOfficialVersion)..." - git tag -a v$($latestOfficialVersion) -m \"Caddy release v$($latestOfficialVersion)\" - Write-Output "Pushing changes to master repository..." - git push -q origin HEAD:master - git push --tags -q origin HEAD:master -} -else -{ - "No changes have been made. Skipping Git Push" -} -Write-Output "Git Operations Complete..." -Write-Output "***************************************" \ No newline at end of file From fca0cc586edb83d9a09118881a92d4e76ac5de52 Mon Sep 17 00:00:00 2001 From: Ryan Borstelmann Date: Sat, 14 Sep 2024 14:44:43 -0500 Subject: [PATCH 2/2] Migrated to automatic tagging --- .github/workflows/main.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce0c357..f3c1b76 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,8 @@ name: Docker Build & Push on: push: - tags: - - "*" + branches: + - main workflow_dispatch: # Allows you to run this workflow manually from the Actions tab env: @@ -33,9 +33,11 @@ jobs: if: success() id: prepare run: | - echo "docker_platform=${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT - echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - + re="^FROM caddy:([^-]+)" + str=$(cat Dockerfile) + tag=$(if [[ $str =~ $re ]]; then echo ${BASH_REMATCH[1]}; else exit 1; fi) + echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -69,3 +71,8 @@ jobs: ghcr.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:${{ steps.prepare.outputs.tag }} quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.prepare.outputs.tag }}