Skip to content

Commit

Permalink
chore: switch to output variable
Browse files Browse the repository at this point in the history
  • Loading branch information
FabiLo22 committed Nov 18, 2024
1 parent a9b2f9f commit 94c480f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ inputs:

# Define your outputs here.
outputs:
deployment_permitted:
description: 'If true, automatic deployment can continue'
deployment_lock:
description: 'If a lock is active, it returns the ID.'

runs:
using: node20
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typescript-action",
"description": "Givve Automatic Deployment",
"version": "v0.1.0",
"version": "v0.1.1",
"author": "PL Gutscheinsysteme GmbH",
"private": true,
"homepage": "https://github.com/givve/github_deployment_action",
Expand Down
33 changes: 18 additions & 15 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ const component = core.getInput('component')
*/
export async function run(): Promise<void> {
try {
const github = new GitHub()
await github.performAuth()

const labels = await github.getLabels()

if (_.includes(labels, 'auto deploy')) {
await checkOrWait()
} else {
const lock = await getLock()
// No lock, we need to lock deployment
if (!lock) {
const { result } = await setLock(component)
if (core.getInput('pull_request') != '') {
const github = new GitHub()
await github.performAuth()

const labels = await github.getLabels()

if (
!_.includes(labels, 'auto deploy') &&
_.includes(labels, 'manual deploy')
) {
const lock = await getLock()
// No lock, we need to lock deployment
if (!lock) {
const { result } = await setLock(component)
}

// Manual deployment, so deployment is not permitted
core.setOutput('deployment_lock', lock.id)
}

// Manual deployment, so deployment is not permitted
core.setFailed('Manual deployment lock active! ID to unlock: ' + lock.id)
}
} catch (error) {
// Fail the workflow run if an error occurs
Expand Down

0 comments on commit 94c480f

Please sign in to comment.