Skip to content

Commit

Permalink
Merge pull request #77 from IAreKyleW00t/feat/readme-versions
Browse files Browse the repository at this point in the history
feat: Adding workflow to automate README tags
  • Loading branch information
IAreKyleW00t authored Aug 31, 2024
2 parents cfab75b + 06d8903 commit cd734c6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cache-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- closed
paths:
- Dockerfile
- .dockerignore

env:
DOCKER_BUILDKIT: "1"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ on:
branches: [main]
paths:
- Dockerfile
- .dockerignore
pull_request:
branches: [main]
paths:
- Dockerfile
- .dockerignore

env:
DOCKER_BUILDKIT: "1"
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/readme-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: README Versions

on:
pull_request:
types: [opened, reopened, synchronize]
branches: [main]
paths:
- Dockerfile

jobs:
readme:
name: Update README versions
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Parse Caddy version
id: caddy
shell: bash
run: |
CADDY_VERSION=$(grep -m 1 -Eo 'caddy:[0-9]+\.[0-9]+\.[0-9]+' Dockerfile \
| sed -E 's/.+:([0-9]+\.[0-9]+\.[0-9]+)(.+)?$/\1/g')
MAJOR=$(echo "$CADDY_VERSION" | cut -d . -f 1)
MINOR=$(echo "$CADDY_VERSION" | cut -d . -f 2)
PATCH=$(echo "$CADDY_VERSION" | cut -d . -f 3)
cat <<EOF | tee -a "$GITHUB_OUTPUT"
version=$CADDY_VERSION
major=$MAJOR
minor=$MINOR
patch=$PATCH
EOF
- name: Update README
shell: bash
env:
VERSION: ${{ steps.caddy.outputs.version }}
MAJOR: ${{ steps.caddy.outputs.major }}
MINOR: ${{ steps.caddy.outputs.minor }}
PATCH: ${{ steps.caddy.outputs.patch }}
run: |
cat > tags.md <<EOF
- [\`latest\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/v$VERSION)
- [\`$VERSION\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/v$VERSION)
- [\`$MAJOR.$MINOR\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/v$MAJOR.$MINOR)
- [\`$MAJOR\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/v$MAJOR)
EOF
awk '
BEGIN{p=1}
$1=="<!--START-TAGS-->"{p=0;print;next}
$1=="<!--END-TAGS-->"{system("cat tags.md");p=1}
p
' README.md > README.md.new
mv README.md.new README.md
rm tags.md
- name: Check if README was updated
id: changed
shell: bash
run: |
if git diff-index --quiet HEAD ; then
echo "changed=false" | tee -a "$GITHUB_OUTPUT"
else
echo "changed=true" | tee -a "$GITHUB_OUTPUT"
fi
- name: Push changes back to PR
if: steps.changed.outputs.changed == 'true'
uses: ChromeQ/commit@99a563633526aeb2d5c2b02b1521accee9a8c896 # v2.x
env:
GH_TOKEN: ${{ github.token }}
with:
ref: ${{ github.event.pull_request.head.ref }}
commit-message: "docs: Updating README for v${{ steps.caddy.outputs.version }}"
files: |
README.md
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ docker pull ghcr.io/iarekylew00t/caddy-cloudflare:latest

## Tags

The following tags are available for the `iarekylew00t/caddy-cloudflare` image.

- `latest`
- `<version>` (eg: `2.6.4`, including: `2.6`, `2`, etc.)

Check the GitHub [Tags](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tags)
for a full list of supported versions!
The following tags are the latest available for the
`iarekylew00t/caddy-cloudflare` image.

<!--START-TAGS-->
- [`latest`](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tree/v2.8.4)
- [`2.8.4`](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tree/v2.8.4)
- [`2.8`](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tree/v2.8)
- [`2`](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tree/v2)
<!--END-TAGS-->

Check the GitHub
[Tags](https://github.com/IAreKyleW00t/docker-caddy-cloudflare/tags)
for a list of all versions!

## Usage

Expand Down

0 comments on commit cd734c6

Please sign in to comment.