Skip to content

Commit 376909e

Browse files
Feature dynamic aliases (#18)
Co-authored-by: Dhenain Ambroise <ambroise.dhenain@gmail.com>
1 parent 3037394 commit 376909e

File tree

12,236 files changed

+434
-2466894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

12,236 files changed

+434
-2466894
lines changed

.github/workflows/run-example-deployment.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,34 @@ jobs:
1010
runs-on: ubuntu-18.04
1111
steps:
1212
- uses: actions/checkout@v2
13+
14+
# Extracts GitHub metadata (branch name, etc.)
15+
- name: Expose GitHub slug/short variables # See https://github.com/rlespinasse/github-slug-action#exposed-github-environment-variables
16+
uses: rlespinasse/github-slug-action@v3.x # See https://github.com/rlespinasse/github-slug-action
17+
1318
- uses: ./
1419
with:
20+
# Deploys examples/static-deployment
1521
command: "yarn deploy:example --token ${{ secrets.VERCEL_TOKEN }}"
1622
applyDomainAliases: true
1723
failIfAliasNotLinked: false
24+
# Uses dynamically resolved additional aliases (e.g: one based on the current branch's name)
25+
# Uses alias that's longer than 63 chars to check if it gets shortened, because of RFC 1035 - See https://vercel.com/support/articles/why-is-my-vercel-deployment-url-being-shortened?query=url%20length#rfc-1035
26+
# github-action-deploy-on-vercel-example-extra-alias-test-limit-alias-length.vercel.app > github-action-deploy-on-vercel-example-extra-alias-test-limit-a.vercel.app (shortened)
27+
# TODO Don't always use GITHUB_REF_SLUG (push) but GITHUB_HEAD_REF_SLUG when event is pull_request - See https://github.com/rlespinasse/github-slug-action/issues/71
28+
extraAliases: >-
29+
github-action-deploy-on-vercel-example-${{ env.GITHUB_REF_SLUG }}.vercel.app,
30+
github-action-deploy-on-vercel-example-extra-alias.vercel.app,
31+
github-action-deploy-on-vercel-example-extra-alias-test-limit-alias-length.vercel.app
32+
1833
env:
1934
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
2035

36+
# TODO Add anti-regression tests to check all aliases have been deployed correctly!
2137
- run: "echo \"Found deployment url: ${{ env.VERCEL_DEPLOYMENT_URL }}\""
22-
- run: "echo \"Created aliases ${{ env.VERCEL_ALIASES_CREATED }}\""
23-
- run: "echo \"Created aliases (full) ${{ env.VERCEL_ALIASES_CREATED_FULL }}\""
24-
38+
- run: "echo \"Created ${{ env.VERCEL_ALIASES_CREATED_COUNT }} aliases\""
39+
- run: "echo \"Created aliases: ${{ env.VERCEL_ALIASES_CREATED }}\""
40+
- run: "echo \"Created aliases (full): ${{ env.VERCEL_ALIASES_CREATED_FULL }}\""
2541
- run: "echo \"Alias markdown generated: ${{ env.VERCEL_ALIASES_CREATED_URLS_MD }}\""
42+
- run: "echo \"Failed ${{ env.VERCEL_ALIASES_FAILED_COUNT }} aliases\""
43+
- run: "echo \"Failed aliases (full): ${{ env.VERCEL_ALIASES_FAILED_FULL }}\""

.github/workflows/run-integration-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ jobs:
1010
runs-on: ubuntu-18.04
1111
steps:
1212
- uses: actions/checkout@v2
13+
- run: yarn # Install all dependencies
1314
- uses: ./
1415
with:
16+
# TODO Explain what this command does, it's unclear. It looks like it's an integration test for parsing the vercel output
1517
command: "yarn test:integration"
1618
applyDomainAliases: true
1719
failIfAliasNotLinked: false
1820
env:
1921
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
22+
# TODO Why is this necessary? Shouldn't it be an output? It's not supposed to be provided as input
2023
VERCEL_DEPLOYMENT_URL: "https://github-action-deploy-on-vercel-example.vercel.app/"
2124

2225
- run: "echo \"Found deployment url: ${{ env.VERCEL_DEPLOYMENT_URL }}\""

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ vcs.xml
8989
.idea/markdown-navigator*/**
9090

9191
# package directories
92-
#node_modules # XXX Necessary for GitHub Actions
92+
node_modules
9393
jspm_packages
9494

9595
# Serverless directories
@@ -127,5 +127,5 @@ yarn-error.log*
127127

128128
# Tmp files (cache, etc.)
129129
*.cache
130-
131130
.vercel
131+
github-action-runtime/stats.json

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,61 @@ The below variables are available as outputs, but are also **injected as environ
8383
- `VERCEL_DEPLOYMENT_DOMAIN`: Url without the protocol declaration, e.g: `xxx.vercel.app`
8484
- `VERCEL_ALIASES_ERROR`: _(optional)_ Vercel errors during domain aliasing
8585
- `VERCEL_ALIASES_CREATED`: List of aliases created successfully, as a string separated by `, ` for each alias
86+
- `VERCEL_ALIASES_CREATED_COUNT`: Number of created aliases
8687
- `VERCEL_ALIASES_CREATED_FULL`: List of aliases created successfully, as a JSON array containing the Vercel's response
88+
- `VERCEL_ALIASES_CREATED_URLS_MD`: List of aliases created successfully, as a Markdown string separated by `, ` for each alias
89+
- `VERCEL_ALIASES_FAILED_COUNT`: Number of aliases that failed to be created
90+
- `VERCEL_ALIASES_FAILED_FULL`: List of aliases that failed, as a JSON array containing the Vercel's response
8791
> Hint: You can use `${{ env.VERCEL_DEPLOYMENT_URL }}` in you GitHub Action to read the deployment URL, after the action has run.
8892

93+
## Advanced examples
94+
95+
### Example with dynamic aliases based on GitHub branch (on `push` event)
96+
97+
```yml
98+
name: 'GitHub Action deploy example'
99+
on:
100+
pull_request:
101+
push:
102+
branches:
103+
- '*'
104+
105+
jobs:
106+
run-example-deployment:
107+
runs-on: ubuntu-18.04
108+
steps:
109+
- uses: actions/checkout@v2
110+
111+
# Extracts GitHub metadata (branch name, etc.)
112+
- name: Expose GitHub slug/short variables # See https://github.com/rlespinasse/github-slug-action#exposed-github-environment-variables
113+
uses: rlespinasse/github-slug-action@v3.x # See https://github.com/rlespinasse/github-slug-action
114+
115+
- uses: ./
116+
with:
117+
# Deploys examples/static-deployment
118+
command: "yarn deploy:example --token ${{ secrets.VERCEL_TOKEN }}"
119+
applyDomainAliases: true
120+
failIfAliasNotLinked: false
121+
# Uses dynamically resolved additional aliases (e.g: one based on the current branch's name)
122+
# Uses alias that's longer than 63 chars to check if it gets shortened, because of RFC 1035 - See https://vercel.com/support/articles/why-is-my-vercel-deployment-url-being-shortened?query=url%20length#rfc-1035
123+
# github-action-deploy-on-vercel-example-extra-alias-test-limit-alias-length.vercel.app > github-action-deploy-on-vercel-example-extra-alias-test-limit-a.vercel.app (shortened)
124+
# TODO Don't always use GITHUB_REF_SLUG (push) but GITHUB_HEAD_REF_SLUG when event is pull_request - See https://github.com/rlespinasse/github-slug-action/issues/71
125+
extraAliases: >-
126+
github-action-deploy-on-vercel-example-${{ env.GITHUB_REF_SLUG }}.vercel.app
127+
128+
env:
129+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
130+
131+
- run: "echo \"Found deployment url: ${{ env.VERCEL_DEPLOYMENT_URL }}\""
132+
- run: "echo \"Created ${{ env.VERCEL_ALIASES_CREATED_COUNT }} aliases\""
133+
- run: "echo \"Created aliases: ${{ env.VERCEL_ALIASES_CREATED }}\""
134+
- run: "echo \"Created aliases (full): ${{ env.VERCEL_ALIASES_CREATED_FULL }}\""
135+
- run: "echo \"Alias markdown generated: ${{ env.VERCEL_ALIASES_CREATED_URLS_MD }}\""
136+
- run: "echo \"Failed ${{ env.VERCEL_ALIASES_FAILED_COUNT }} aliases\""
137+
- run: "echo \"Failed aliases (full): ${{ env.VERCEL_ALIASES_FAILED_FULL }}\""
138+
```
139+
140+
89141
## :hugs: Community examples :heart:
90142

91143
Here are a few community-powered examples, those are usually advanced use-cases!

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
description: 'If true, will throw an error (and crash CI) when there is an error about aliases link'
1616
required: false
1717
default: "false"
18+
extraAliases:
19+
description: 'List of additional aliases to create, will be added to the aliases specified in the vercel.json:aliases file'
20+
required: false
1821
outputs:
1922
VERCEL_DEPLOYMENT_URL:
2023
description: "Full Vercel deployment url (parsed from the deployment logs), e.g: https://xxx.vercel.app"
@@ -24,4 +27,4 @@ outputs:
2427
description: "(optional) Vercel errors during domain aliasing"
2528
runs:
2629
using: 'node12'
27-
main: 'lib/main.js'
30+
main: 'github-action-runtime/index.js'

examples/static-deployment/vercel.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "github-action-deploy-on-vercel-example",
44
"scope": "team_qnVfSEVc2WwmOE1OYhZr4VST",
55
"alias": [
6-
"github-action-deploy-on-vercel-example-alias.vercel.app",
7-
"deploy-on-vercel-example.vercel.app"
6+
"github-action-deploy-on-vercel-example-static-alias.vercel.app",
7+
"github-action-deploy-on-vercel-example-static-alias2.vercel.app"
88
]
99
}

github-action-runtime/LICENSE

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
@actions/core
2+
MIT
3+
The MIT License (MIT)
4+
5+
Copyright 2019 GitHub
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
9+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
13+
@actions/exec
14+
MIT
15+
16+
@actions/glob
17+
MIT
18+
The MIT License (MIT)
19+
20+
Copyright 2019 GitHub
21+
22+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
23+
24+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
25+
26+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27+
28+
@actions/io
29+
MIT
30+
31+
@vercel/ncc
32+
MIT
33+
Copyright 2018 ZEIT, Inc.
34+
35+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
36+
37+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
38+
39+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40+
41+
balanced-match
42+
MIT
43+
(MIT)
44+
45+
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
46+
47+
Permission is hereby granted, free of charge, to any person obtaining a copy of
48+
this software and associated documentation files (the "Software"), to deal in
49+
the Software without restriction, including without limitation the rights to
50+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
51+
of the Software, and to permit persons to whom the Software is furnished to do
52+
so, subject to the following conditions:
53+
54+
The above copyright notice and this permission notice shall be included in all
55+
copies or substantial portions of the Software.
56+
57+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63+
SOFTWARE.
64+
65+
66+
brace-expansion
67+
MIT
68+
MIT License
69+
70+
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
71+
72+
Permission is hereby granted, free of charge, to any person obtaining a copy
73+
of this software and associated documentation files (the "Software"), to deal
74+
in the Software without restriction, including without limitation the rights
75+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
76+
copies of the Software, and to permit persons to whom the Software is
77+
furnished to do so, subject to the following conditions:
78+
79+
The above copyright notice and this permission notice shall be included in all
80+
copies or substantial portions of the Software.
81+
82+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
83+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
84+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
85+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
86+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
87+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
88+
SOFTWARE.
89+
90+
91+
concat-map
92+
MIT
93+
This software is released under the MIT license:
94+
95+
Permission is hereby granted, free of charge, to any person obtaining a copy of
96+
this software and associated documentation files (the "Software"), to deal in
97+
the Software without restriction, including without limitation the rights to
98+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
99+
the Software, and to permit persons to whom the Software is furnished to do so,
100+
subject to the following conditions:
101+
102+
The above copyright notice and this permission notice shall be included in all
103+
copies or substantial portions of the Software.
104+
105+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
106+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
107+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
108+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
109+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
110+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
111+
112+
113+
minimatch
114+
ISC
115+
The ISC License
116+
117+
Copyright (c) Isaac Z. Schlueter and Contributors
118+
119+
Permission to use, copy, modify, and/or distribute this software for any
120+
purpose with or without fee is hereby granted, provided that the above
121+
copyright notice and this permission notice appear in all copies.
122+
123+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
124+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
125+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
126+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
127+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
128+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
129+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
130+
131+
132+
node-fetch
133+
MIT
134+
The MIT License (MIT)
135+
136+
Copyright (c) 2016 David Frank
137+
138+
Permission is hereby granted, free of charge, to any person obtaining a copy
139+
of this software and associated documentation files (the "Software"), to deal
140+
in the Software without restriction, including without limitation the rights
141+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
142+
copies of the Software, and to permit persons to whom the Software is
143+
furnished to do so, subject to the following conditions:
144+
145+
The above copyright notice and this permission notice shall be included in all
146+
copies or substantial portions of the Software.
147+
148+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
149+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
150+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
151+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
152+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
153+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
154+
SOFTWARE.

github-action-runtime/index.js

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

github-action-runtime/index.js.map

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

github-action-runtime/sourcemap-register.js

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

lib/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ const runConfigChecks = () => {
5050
* Runs the GitHub Action.
5151
*/
5252
const run = () => __awaiter(void 0, void 0, void 0, function* () {
53+
var _a;
5354
if (!core.isDebug()) {
5455
core.info('Debug mode is disabled. Read more at https://github.com/UnlyEd/github-action-await-vercel#how-to-enable-debug-logs');
5556
}
5657
try {
5758
const command = core.getInput('command');
59+
const extraAliases = (_a = core.getInput('extraAliases')) === null || _a === void 0 ? void 0 : _a.split(', ');
5860
const applyDomainAliases = core.getInput('applyDomainAliases') == 'true';
5961
const failIfAliasNotLinked = core.getInput('failIfAliasNotLinked') == 'true';
6062
core.debug(`Received command: ${command}`); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#how-to-access-step-debug-logs
6163
core.debug(`Should we deploy aliases ? "${applyDomainAliases}"`);
62-
yield vercel_1.default(command, applyDomainAliases, failIfAliasNotLinked);
64+
console.log(`|${extraAliases}|`);
65+
yield vercel_1.default(command, applyDomainAliases, failIfAliasNotLinked, extraAliases);
6366
}
6467
catch (error) {
6568
core.setFailed(error.message);

0 commit comments

Comments
 (0)