diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d19812c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/** \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4baf5a8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM alpine:latest - -RUN apk add --no-cache git - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 658a465..00c4867 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,13 @@ It would be more useful to use this with other GitHub Actions' outputs. ## Inputs -| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT | -| --------- | -------------------------- | -------- | -------- | ------- | -| `tag` | A Git tag name. | `string` | `true` | `N/A` | -| `message` | A message for the Git tag. | `string` | `false` | `''` | +| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT | +| ------------ | -------------------------------------- | -------- | -------- | ------- | +| `tag` | A Git tag name. | `string` | `true` | `N/A` | +| `message` | A message for the Git tag. | `string` | `false` | `''` | +| `ref` | Commit SHA or tag to target. | `string` | `false` | `''` | +| `force` | A message for the Git tag. | `boolean`| `false` | `false` | +| `always-pass`| If step should pass if tag push fails | `boolean`| `false` | `false` | ## Example @@ -34,13 +37,13 @@ jobs: - uses: actions-ecosystem/action-get-latest-tag@v1 id: get-latest-tag - - uses: actions-ecosystem/action-bump-semver@v1 + - uses: thejeff77/action-bump-semver@v1.0.0 id: bump-semver with: current_version: ${{ steps.get-latest-tag.outputs.tag }} level: minor - - uses: actions-ecosystem/action-push-tag@v1 + - uses: thejeff77/action-push-tag@v1.0.0 with: tag: ${{ steps.bump-semver.outputs.new_version }} message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}' diff --git a/action.yml b/action.yml index 5bf8ceb..3e987fc 100644 --- a/action.yml +++ b/action.yml @@ -1,16 +1,63 @@ -name: Actions Ecosystem Action Push Tag -description: Push a Git tag. -author: Actions Ecosystem +name: Push Any Git Tag +description: based on Actions Ecosystem Push Tag - Fixed with additional features. +author: Actions Ecosystem & theJeff77 + inputs: tag: description: A Git tag name. + type: string required: true message: description: A message for the Git tag. + type: string required: false + ref: + description: Commit SHA or ref (tag) to target for the tag. + type: string + required: false + force: + description: Whether or not to force push (overwrite) the tag if it already exists. Useful for walking tags. + type: boolean + required: false + default: false + always-pass: + description: If this build step should pass no matter what if ref is missing and the tag push fails. + type: boolean + required: false + default: false runs: - using: docker - image: Dockerfile + using: "composite" + steps: + - name: Tag + shell: bash + run: | + tag=${{ inputs.tag }} + message=${{ inputs.message }} + ref=${{ inputs.ref }} + force=${{ inputs.force }} + alwaysPass=${{ inputs.always-pass }} + + if [ "$force" = "true" ]; then + force="-f" + else + unset force + fi + + if [ "$always-pass" = "true" ]; then + alwaysPass=" || true" + else + unset alwaysPass + fi + + if [ -z "$ref" ]; then + ref="HEAD" + fi + + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + git tag -a "${tag}" "${ref}" -m "${message}" ${force} ${alwaysPass} + git push origin "${tag}" ${force} ${alwaysPass} branding: icon: search color: yellow diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 8be0e8d..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -tag=${INPUT_TAG} -message=${INPUT_MESSAGE} - -git config user.name "${GITHUB_ACTOR}" -git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - -git tag -a "${tag}" -m "${message}" -git push origin "${tag}"