-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
99 lines (97 loc) · 3.78 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
name: 'gitStream repo agent'
description: 'Public GitHub action for gitStream Continuous Merge'
inputs:
full_repository:
description: 'Path of full Repository'
required: true
head_ref:
description: 'Head Branch Ref to checkout to'
required: true
base_ref:
description: 'Base Branch Ref to checkout to'
required: true
client_payload:
description: 'The client payload'
required: true
installation_id:
description: 'The github app installation id'
required: false
resolver_url:
description: 'Resolver url to send results to'
required: true
resolver_token:
description: 'Optional token for resolver'
required: false
debug_mode:
description: 'Run parser in debug mode'
required: false
default: false
runs:
using: 'composite'
steps:
- name: Set start time
id: start
run: echo "timestamp=$EPOCHSECONDS" >> $GITHUB_OUTPUT
shell: bash
- name: Create GitStream folder
id: create-gitstream-folder
shell: bash
run: |
mkdir gitstream
cd gitstream
mkdir repo
- name: Cache gitstream results
id: cache-gitstream-results
uses: actions/cache@v3
with:
path: gitstream/cache.json
key: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).headSha }}-gitsream-cache
- name: Checkout head branch
uses: actions/checkout@v3
if: ${{ steps.cache-gitstream-results.outputs.cache-hit != 'true' }}
with:
repository: ${{ inputs.full_repository }}
ref: ${{ github.event.inputs.head_ref }}
path: 'gitstream/repo/'
token: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).githubToken || github.token }}
- if: ${{ steps.cache-gitstream-results.outputs.cache-hit != 'true' }}
run: |
all=2147483647
cd gitstream
cd repo
git fetch --deepen=$all origin ${{ github.event.inputs.base_ref }}
git checkout -b ${{ github.event.inputs.base_ref }} origin/${{ github.event.inputs.base_ref }}
git checkout ${{ github.event.inputs.head_ref }}
git fetch --deepen=$all origin ${{ github.event.inputs.head_ref }}
shell: bash
- name: Create cm folder
id: create-cm-folder
shell: bash
run: |
cd gitstream
mkdir cm
- name: Checkout cm repo
uses: actions/checkout@v3
if: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).hasCmRepo == true }}
with:
repository: '${{ fromJSON(fromJSON(github.event.inputs.client_payload)).owner }}/${{ fromJSON(fromJSON(github.event.inputs.client_payload)).cmRepo }}'
ref: ${{ fromJSON(fromJSON(github.event.inputs.client_payload)).cmRepoRef }}
path: 'gitstream/cm/'
- name: Run The Action
id: gitstream-action
if: always()
run: |
SECONDS=0
env_file=env.user
touch $env_file
for var in $(env | cut -d "=" -f 1); do
value="${!var}"
echo "$var=$value" >> "$env_file"
done
docker pull gitstream/rules-engine:latest
echo "docker-pull-duration=$SECONDS" >> $GITHUB_OUTPUT
SECONDS=0
docker run --env-file $env_file -v $(pwd)/gitstream:/code -e USE_CACHE=${{ steps.cache-gitstream-results.outputs.cache-hit }} -e HEAD_REF=${{ github.event.inputs.head_ref }} -e BASE_REF=${{ github.event.inputs.base_ref }} -e CLIENT_PAYLOAD=${{ github.event.inputs.client_payload }} -e RULES_RESOLVER_URL=${{ github.event.inputs.resolver_url }} -e RULES_RESOLVER_TOKEN=${{ github.event.inputs.resolver_token }} -e DEBUG_MODE=${{ github.event.inputs.debug_mode }} gitstream/rules-engine
echo "docker-run-duration=$SECONDS" >> $GITHUB_OUTPUT
echo "action-run-duration=$(($EPOCHSECONDS - ${{ steps.start.outputs.timestamp }}))" >> $GITHUB_OUTPUT
shell: bash