Skip to content

Commit

Permalink
Merge pull request #143 from smlx/action
Browse files Browse the repository at this point in the history
feat: turn repository into a Github action
  • Loading branch information
smlx authored May 24, 2024
2 parents ea612e5 + 6dde6f6 commit 6623a0b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ updates:
update-types:
- "minor"
- "patch"
- package-ecosystem: docker
commit-message:
prefix: chore
include: scope
directory: /
schedule:
interval: monthly
groups:
docker:
patterns:
- "*"
update-types:
- "minor"
- "patch"
- package-ecosystem: gomod
commit-message:
prefix: chore
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:3.20
RUN apk --no-cache add curl git jq \
&& (if echo "$TARGETPLATFORM" | grep -q arm; then \
curl -sSL $(curl -s https://api.github.com/repos/smlx/ccv/releases/latest | jq -r '.assets[].browser_download_url | select(test("linux_arm64"))'); \
else \
curl -sSL $(curl -s https://api.github.com/repos/smlx/ccv/releases/latest | jq -r '.assets[].browser_download_url | select(test("linux_amd64"))'); \
fi) \
| tar -xz -C /usr/local/bin ccv
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
10 changes: 10 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Conventional Commits Versioner Action
description: Automatically tag a new version based on the commit messages of commits since the last tag.
outputs:
new_tag:
description: Either "true" or "false" depending on whether a new tag was pushed.
new_tag_version:
description: The new version that was tagged. This will only be set if new_tag=true.
runs:
using: docker
image: Dockerfile
14 changes: 14 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu
# https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action#accessing-files-created-by-a-container-action
cd /github/workspace
# if the ccv tag exists, just exit
if [ "$(git tag -l "$(ccv)")" ]; then
echo "new_tag=false" >>"$GITHUB_OUTPUT"
exit
fi
# if it doesn't, tag and push
git tag "$(ccv)"
git push --tags
echo "new_tag=true" >>"$GITHUB_OUTPUT"
echo "new_tag_version=$(git tag --points-at HEAD)" >>"$GITHUB_OUTPUT"

0 comments on commit 6623a0b

Please sign in to comment.