Skip to content

Commit 267b96d

Browse files
Merge pull request #12 from codemagic-ci-cd/fix/node24-top-level-await
Fix Node 24 runtime compatibility
2 parents 23a10b1 + 6b805fb commit 267b96d

5 files changed

Lines changed: 73 additions & 103 deletions

File tree

dist/LICENSE

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,30 +1099,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
10991099
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11001100

11011101

1102-
proxy-from-env
1103-
MIT
1104-
The MIT License
1105-
1106-
Copyright (C) 2016-2018 Rob Wu <rob@robwu.nl>
1107-
1108-
Permission is hereby granted, free of charge, to any person obtaining a copy of
1109-
this software and associated documentation files (the "Software"), to deal in
1110-
the Software without restriction, including without limitation the rights to
1111-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
1112-
of the Software, and to permit persons to whom the Software is furnished to do
1113-
so, subject to the following conditions:
1114-
1115-
The above copyright notice and this permission notice shall be included in all
1116-
copies or substantial portions of the Software.
1117-
1118-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1119-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1120-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1121-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1122-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1123-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1124-
1125-
11261102
tr46
11271103
MIT
11281104

dist/index.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
{
2-
"type": "module"
3-
}
1+
{}

index.js

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,78 @@
1-
import axios from 'axios'
1+
const axios = require('axios')
2+
const { getInput, getMultilineInput, setFailed, setOutput } = require('@actions/core')
3+
const { context } = require('@actions/github')
24

3-
import {
4-
getInput,
5-
getMultilineInput,
6-
setFailed,
7-
setOutput,
8-
} from '@actions/core'
9-
import { context } from '@actions/github'
5+
async function run() {
6+
const appId = getInput('app-id')
7+
const workflowId = getInput('workflow-id')
8+
const token = getInput('token')
109

11-
const appId = getInput('app-id')
12-
const workflowId = getInput('workflow-id')
13-
const token = getInput('token')
10+
const labels = getMultilineInput('labels')
1411

15-
const labels = getMultilineInput('labels')
12+
let branch = getInput('branch')
13+
let tag = getInput('tag')
1614

17-
let branch = getInput('branch')
18-
let tag = getInput('tag')
19-
20-
if (!branch && !tag) {
21-
const { ref } = context
22-
branch = ref.split('refs/heads/')[1] || process.env.GITHUB_HEAD_REF
23-
tag = ref.split('refs/tags/')[1]
24-
}
25-
26-
const variables = Object.keys(process.env).reduce((variables, variable) => {
27-
if (variable.startsWith('CM_')) {
28-
variables[variable.substring(3)] = process.env[variable]
15+
if (!branch && !tag) {
16+
const { ref } = context
17+
branch = ref.split('refs/heads/')[1] || process.env.GITHUB_HEAD_REF
18+
tag = ref.split('refs/tags/')[1]
2919
}
30-
return variables
31-
}, {})
3220

33-
const softwareVersions = [
34-
'xcode',
35-
'flutter',
36-
'cocoapods',
37-
'node',
38-
'npm',
39-
'ndk',
40-
'java',
41-
'ruby',
42-
].reduce((softwareVersions, software) => {
43-
const version = getInput(software)
44-
if (version) {
45-
softwareVersions[software] = version
46-
}
47-
return softwareVersions
48-
}, {})
21+
const variables = Object.keys(process.env).reduce((variables, variable) => {
22+
if (variable.startsWith('CM_')) {
23+
variables[variable.substring(3)] = process.env[variable]
24+
}
25+
return variables
26+
}, {})
4927

50-
const url = 'https://api.codemagic.io/builds'
28+
const softwareVersions = [
29+
'xcode',
30+
'flutter',
31+
'cocoapods',
32+
'node',
33+
'npm',
34+
'ndk',
35+
'java',
36+
'ruby',
37+
].reduce((softwareVersions, software) => {
38+
const version = getInput(software)
39+
if (version) {
40+
softwareVersions[software] = version
41+
}
42+
return softwareVersions
43+
}, {})
5144

52-
const payload = {
53-
appId,
54-
workflowId,
55-
labels,
56-
branch,
57-
tag,
58-
environment: { variables, softwareVersions },
59-
}
45+
const url = 'https://api.codemagic.io/builds'
6046

61-
const headers = {
62-
'x-auth-token': token,
63-
}
47+
const payload = {
48+
appId,
49+
workflowId,
50+
labels,
51+
branch,
52+
tag,
53+
environment: { variables, softwareVersions },
54+
}
55+
56+
const headers = {
57+
'x-auth-token': token,
58+
}
6459

65-
try {
66-
const response = await axios.post(url, payload, { headers })
60+
try {
61+
const response = await axios.post(url, payload, { headers })
6762

68-
const { buildId } = await response.data
69-
setOutput('build-id', buildId)
70-
setOutput('build-api-url', `https://api.codemagic.io/builds/${buildId}`)
71-
setOutput('build-url', `https://codemagic.io/app/${appId}/build/${buildId}`)
72-
} catch (error) {
73-
let details = null
74-
if (error.response.status === 403) {
75-
details = 'Either app ID or token is incorrect'
76-
} else {
77-
details = error.response.data.error
63+
const { buildId } = response.data
64+
setOutput('build-id', buildId)
65+
setOutput('build-api-url', `https://api.codemagic.io/builds/${buildId}`)
66+
setOutput('build-url', `https://codemagic.io/app/${appId}/build/${buildId}`)
67+
} catch (error) {
68+
let details = null
69+
if (error.response.status === 401 || error.response.status === 403) {
70+
details = 'Either app ID or token is incorrect'
71+
} else {
72+
details = error.response.data.error
73+
}
74+
setFailed(`${error.message}: ${details}`)
7875
}
79-
setFailed(`${error.message}: ${details}`)
8076
}
8177

78+
run()

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"repository": "git@github.com:codemagic-ci-cd/trigger-codemagic-workflow-action.git",
77
"author": "Artemii Yanushevskyi <artemii@nevercode.io>",
88
"license": "MIT",
9-
"type": "module",
10-
"dependencies": {
9+
"dependencies": {
1110
"@actions/core": "^1.10.0",
1211
"@actions/github": "^5.1.1",
1312
"axios": "^1.1.3"

0 commit comments

Comments
 (0)