From 6dde6f6bb1f6eef0ab5c42b85ef03fb6f02fb119 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 24 May 2024 21:06:35 +0800 Subject: [PATCH] feat: turn repository into a Github action --- .github/dependabot.yaml | 14 ++++++++++++++ Dockerfile | 10 ++++++++++ action.yaml | 10 ++++++++++ entrypoint.sh | 14 ++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 action.yaml create mode 100755 entrypoint.sh diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index d65d2b2..c344a50 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..39204d5 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..72af106 --- /dev/null +++ b/action.yaml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..807e414 --- /dev/null +++ b/entrypoint.sh @@ -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"