Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: turn repository into a Github action #143

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading