-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
111 lines (101 loc) · 5.77 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: 'New deployment tool'
description: 'Deploy your project with ease'
inputs:
github_token:
description: 'GITHUB_TOKEN or a repo scoped PAT.'
default: ${{ github.token }}
version:
description: 'Version of the CLI to use.'
default: 'alpha' # using branch name for now for easier deployments
deploy_commands:
description: 'List of commands to run to deploy your project.'
required: true
default: ''
analyze_commits_config:
description: 'Configure the behavior when analyzing commits.'
default: ''
simulated_merge_type:
description: 'When running in a pull request, what type of merge to simulate to run the tool in test mode. Note: This input option is planned to go away in favor of reading github repo settings. Options: merge, squash, rebase.'
default: 'merge' # options: merge, squash, rebase
make_pull_request_comment:
description: 'If a pull request comment should be made. Value is string values "true" or "false".'
default: 'true'
outputs:
new_release_version:
description: 'If a new release was created, this is the version of that release.'
value: ${{ steps.deployment.outputs.new_release_version }}
test_mode_on:
description: 'If test mode was on when the tool ran. Value is string values "true" or "false".'
value: ${{ steps.deployment.outputs.test_mode_on }}
runs:
using: "composite"
steps:
- name: Install Deno runtime to run the CLI
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Find pull request comment previously created, if there is one.
if: ${{ github.event_name == 'pull_request' }}
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- new-deployment-tool-deploy-run-output -->'
token: ${{ inputs.github_token }}
- name: Create or update pull request comment with new deployment tool output
uses: peter-evans/create-or-update-comment@v4
if: ${{ github.event_name == 'pull_request' && inputs.make_pull_request_comment == 'true' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- new-deployment-tool-deploy-run-output -->
## New deployment tool results
Running deployment...refresh webpage to see results when done.
edit-mode: replace
- name: Run deployment tool
# Deno's runtime permissions are a great feature. It would be nice to take advantage of it, however, it may not be possible with future features like running plugins.
#
# The directories we are giving permission to read and write to are the temp directories for all of the OSes that GitHub Actions supports. /tmp for linux and /var/folders for macOS.
run: deno run --allow-env=GITHUB_OUTPUT,GITHUB_EVENT_PATH,GITHUB_REF,GITHUB_HEAD_REF,GITHUB_EVENT_NAME,GITHUB_REPOSITORY,INPUT_GITHUB_TOKEN,INPUT_DEPLOY_COMMANDS,INPUT_ANALYZE_COMMITS_CONFIG --allow-net="api.github.com" --allow-run --allow-read="/tmp,/var/folders,/home/runner/work/_temp" --allow-write="/tmp,/var/folders,/home/runner/work/_temp" https://raw.githubusercontent.com/levibostian/new-deployment-tool/${{ inputs.version }}/index.ts
id: deployment
shell: bash
env:
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_DEPLOY_COMMANDS: ${{ inputs.deploy_commands }}
INPUT_ANALYZE_COMMITS_CONFIG: ${{ inputs.analyze_commits_config }}
- name: Pull request comment if the deployment failed
uses: peter-evans/create-or-update-comment@v4
if: ${{ inputs.make_pull_request_comment == 'true' && steps.deployment.outputs.test_mode_on == 'true' && steps.deployment.outcome != 'success' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- new-deployment-tool-deploy-run-output -->
## New deployment tool results
There was a failure when running the deployment. Check [the logs](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) to see what went wrong.
edit-mode: replace
- name: Pull request comment if there will be a release
uses: peter-evans/create-or-update-comment@v4
if: ${{ inputs.make_pull_request_comment == 'true' && steps.deployment.outputs.test_mode_on == 'true' && steps.deployment.outcome == 'success' && steps.deployment.outputs.new_release_version != '' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- new-deployment-tool-deploy-run-output -->
## New deployment tool results
If this pull request and all of it's parent pull requests are merged, a new release will be created.
The next version of the project will be: ${{ steps.deployment.outputs.new_release_version }}
edit-mode: replace
- name: Pull request comment if there will not be a release
uses: peter-evans/create-or-update-comment@v4
if: ${{ inputs.make_pull_request_comment == 'true' && steps.deployment.outputs.test_mode_on == 'true' && steps.deployment.outcome == 'success' && steps.deployment.outputs.new_release_version == '' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- new-deployment-tool-deploy-run-output -->
## New deployment tool results
This pull request and all of it's parent pull requests do not have any changes that would trigger a new release.
edit-mode: replace