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

Use ${{github.token}} as default #8

Merged
merged 2 commits into from
Nov 30, 2022
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
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
pull_request:
push:
branches:
- master

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'tag-exists-action: true'
id: checkTag
uses: ./
with:
tag: 'v1.0.0'
- name: 'tag-exists-action: false'
id: notExist
uses: ./
with:
tag: 'not-exist-tag-for-testing'

- name: Result of checkTag
run: test "true" = "${{ steps.checkTag.outputs.exists }}"
- name: Result of notExist
run: test "false" = "${{ steps.notExist.outputs.exists }}"
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ A Github action that determines if a tag exists

**Required** The tag to search for.

### `github_token`

GitHub token. default: `${{github.token}}`

## Outputs

### `exists`
Expand All @@ -20,8 +24,6 @@ a string value of 'true' or 'false'
id: checkTag
with:
tag: 'v1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: echo ${{ steps.checkTag.outputs.exists }}
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
tag:
description: 'Tag to search for'
required: true
github_token:
description: GitHub token
default: ${{ github.token }}
outputs:
exists: # id of output
description: 'true or false'
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function run() {
// Get owner and repo from context of payload that triggered the action
const { owner, repo } = context.repo

const github = new GitHub(process.env.GITHUB_TOKEN);
const github = new GitHub(process.env.GITHUB_TOKEN || core.getInput('github_token'));
var exists = 'false';

try {
Expand Down