-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.29 KB
/
workflow_dispatch.yml
File metadata and controls
45 lines (43 loc) · 1.29 KB
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
name: workflow_dispatch
on:
workflow_dispatch:
inputs:
commit-sha:
description: 'the commit sha to redeploy'
required: false
pull_request:
types:
- opened
- synchronize
jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.setCommit.outputs.result }}
steps:
- name: set commit
id: setCommit
uses: actions/github-script@v5
with:
script: |
if (context.payload.inputs && context.payload.inputs.commit-sha) {
return context.payload.inputs.commit-sha
}
const { data: { workflow_runs }} = await github.rest.actions.listWorkflowRuns({
owner: 'ebk45',
repo: 'github-actions',
workflow_id: 'cd-workflow.yml',
status: 'success',
exclude_pull_requests: true
});
console.log(workflow_runs[0])
const latestSuccessfulCommit = workflow_runs[0].head_sha;
console.log({latestSuccessfulCommit})
return latestSuccessfulCommit
result-encoding: string
redeploy-preview:
needs: check-commit
runs-on: ubuntu-latest
steps:
- name: check commit
run: echo "${{ needs.check-commit.outputs.commit }}"