Skip to content

Commit

Permalink
use env
Browse files Browse the repository at this point in the history
see actions/github-script#287

chore: change variable names
  • Loading branch information
v1v committed Nov 7, 2023
1 parent 94c712c commit 4d09e6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
19 changes: 12 additions & 7 deletions .github/actions/oblt-cli-cluster-credentials/action.yml
Expand Up @@ -24,16 +24,19 @@ runs:
steps:
- name: Process inputs
uses: actions/github-script@v6
env:
CLUSTER_NAME_INPUT: ${{ inputs.cluster-name }}
CLUSTER_INFO_FILE_INPUT: ${{ inputs.cluster-info-file }}
with:
script: |
const clusterName = core.getInput('cluster-name')
const clusterInfoFile = core.getInput('cluster-info-file')
const clusterNameInput = process.env.CLUSTER_NAME_INPUT
const clusterInfoFile = process.env.CLUSTER_INFO_FILE_INPUT
if (clusterName && clusterInfoFile) {
if (clusterNameInput && clusterInfoFile) {
core.setFailed(`Either cluster-name or cluster-info-file but no both`)
}
var cluster = clusterName
var clusterName = clusterNameInput
if (clusterInfoFile) {
const fs = require('fs')
Expand All @@ -42,13 +45,15 @@ runs:
if (jsonObject && jsonObject.ClusterName === undefined) {
core.setFailed(`cluster-info-file does not contain the field ClusterName`)
}
cluster = jsonObject.ClusterName
clusterName = jsonObject.ClusterName
}
if (cluster.trim().length === 0) {
if (clusterName.trim().length === 0) {
core.setFailed(`cluster name is empty`)
}
core.exportVariable('CLUSTER_NAME', `${cluster}`)
console.log(`clusterName is "${clusterName}"`)
core.exportVariable('CLUSTER_NAME', `${clusterName}`)
- uses: elastic/apm-pipeline-library/.github/actions/setup-oblt-cli@current
with:
Expand Down
19 changes: 12 additions & 7 deletions .github/actions/oblt-cli-destroy-cluster/action.yml
Expand Up @@ -15,16 +15,19 @@ runs:
steps:
- name: Process inputs
uses: actions/github-script@v6
env:
CLUSTER_NAME_INPUT: ${{ inputs.cluster-name }}
CLUSTER_INFO_FILE_INPUT: ${{ inputs.cluster-info-file }}
with:
script: |
const clusterName = core.getInput('cluster-name')
const clusterInfoFile = core.getInput('cluster-info-file')
const clusterNameInput = process.env.CLUSTER_NAME_INPUT
const clusterInfoFile = process.env.CLUSTER_INFO_FILE_INPUT
if (clusterName && clusterInfoFile) {
if (clusterNameInput && clusterInfoFile) {
core.setFailed(`Either cluster-name or cluster-info-file but no both`)
}
var cluster = clusterName
var clusterName = clusterNameInput
if (clusterInfoFile) {
const fs = require('fs')
Expand All @@ -33,13 +36,15 @@ runs:
if (jsonObject && jsonObject.ClusterName === undefined) {
core.setFailed(`cluster-info-file does not contain the field ClusterName`)
}
cluster = jsonObject.ClusterName
clusterName = jsonObject.ClusterName
}
if (cluster.trim().length === 0) {
if (clusterName.trim().length === 0) {
core.setFailed(`cluster name is empty`)
}
core.exportVariable('CLUSTER_NAME', `${cluster}`)
console.log(`clusterName is "${clusterName}"`)
core.exportVariable('CLUSTER_NAME', `${clusterName}`)
- uses: elastic/apm-pipeline-library/.github/actions/oblt-cli@current
with:
Expand Down

0 comments on commit 4d09e6b

Please sign in to comment.