Skip to content

Commit

Permalink
feat: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ovsds committed Jul 19, 2024
1 parent 2ba5c93 commit 6452874
Show file tree
Hide file tree
Showing 7 changed files with 2,080 additions and 24 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: E2E

on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
e2e-default:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Get Tag Info
uses: ./
with:
owner: ovsds
repo: push-version-tags-action
name: v1

- name: Validate Results
run: |
# Validate exists equals true
exists=${{ steps.get-tag.outputs.exists }}
[[ "$exists" == "true" ]] || {echo 'Output `exists` does not equal "true"'; false}
3 changes: 1 addition & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname $0)/.huskyrc"
. "$(dirname $0)/_/husky.sh"

npx --no -- commitlint --edit
npx --no -- commitlint --edit
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env sh
. "$(dirname $0)/.huskyrc"
. "$(dirname $0)/_/husky.sh"

Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![CI](https://github.com/ovsds/get-tag-info-action/workflows/Check%20PR/badge.svg)](https://github.com/ovsds/get-tag-info-action/actions?query=workflow%3A%22%22Check+PR%22%22)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Get%20Tag%20Info-blue.svg)](https://github.com/marketplace/actions/get-tag-info)

Get Tag Info Action
Gets information for a tag.

## Usage

Expand All @@ -15,15 +15,20 @@ Get Tag Info Action

### Action Inputs

| Name | Description | Default |
| ------------- | ------------ | ------- |
| `placeholder` | Placeholder. | |
| Name | Description | Default |
| -------------- | ------------------------------------------------------------------ | ----------------------------------- |
| `github_token` | Github token used for API calls. Required scope - 'contents: read' | ${{ github.token }} |
| `owner` | Repository owner. | ${{ github.repository_owner }} |
| `repo` | Repository name. | ${{ github.event.repository.name }} |
| `tag_name` | Tag name. | |

### Action Outputs

| Name | Description |
| ------------- | ------------ |
| `placeholder` | Placeholder. |
| Name | Description |
| ---------- | ----------- |
| `exists` | Tag exists. |
| `tag_name` | Tag name. |
| `tag_sha` | Tag SHA. |

## Development

Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tasks:

- echo 'Installing node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm clean-install" }
vars: { COMMAND: "npm install" }

- echo 'Installing husky pre-commit...'
- task: _with_nvm
Expand Down
80 changes: 67 additions & 13 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,81 @@
name: "Get Tag Info Action"
description: "Get Tag Info Action"
name: "Get Tag Info"
description: "Returns tag information for the given tag name"

inputs:
placeholder:
description: "Placeholder input to be replaced by real inputs"
github_token:
description: "Github token used for API calls. Required scope - 'contents: read'"

owner:
description: "Owner of the repository"

repo:
description: "Repository name"

tag_name:
description: "Target tag name"
required: true
default: "placeholder"

outputs:
placeholder:
description: "Placeholder output to be replaced by real outputs"
value: ${{steps.placeholder.outputs.placeholder }}
exists:
description: "Tag exists"
value: ${{ steps.get-ref.outputs.exists }}

tag_name:
description: "Tag name"
value: ${{ steps.get-tag.outputs.tag }}

tag_sha:
description: "Tag SHA"
value: ${{ steps.get-tag.outputs.sha }}

runs:
using: "composite"
steps:
- name: Placeholder
id: placeholder
- name: Ensure owner
id: ensure-owner
shell: bash
run: |
# Ensuring `owner` input, using repository owner if not provided
owner=${{ inputs.owner }}
if [[ -z "$owner" ]]; then
owner=${{ github.repository_owner }}
fi
echo "owner=${owner}" >> $GITHUB_OUTPUT
- name: Ensure repo
id: ensure-repo
shell: bash
run: |
# Ensuring `repo` input, using repository if not provided
repo=${{ inputs.repo }}
if [[ -z "$repo" ]]; then
repo=${{ github.event.repository.name }}
fi
echo "repo=${repo}" >> $GITHUB_OUTPUT
- name: Ensure token
id: ensure-token
shell: bash
run: |
# Ensuring `github_token` input, using `github.token` variable if not provided
github_token=${{ inputs.github_token }}
if [[ -z "$github_token" ]]; then
github_token=${{ github.token }}
fi
echo "github_token=${github_token}" >> $GITHUB_OUTPUT
- name: Get ref
id: get-ref
shell: bash
run: |
echo "::set-output name=placeholder::${{ inputs.placeholder }}"
# Getting tag ref information
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ steps.ensure-owner.outputs.owner }}/${{ steps.ensure-repo.outputs.repo }}/git/refs/tags/${{ inputs.tag_name }}
env:
GH_TOKEN: ${{ steps.ensure-token.outputs.github_token }}

# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
branding:
icon: "message-square"
icon: "tag"
color: "gray-dark"
Loading

0 comments on commit 6452874

Please sign in to comment.