-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
58 lines (54 loc) · 2.16 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
name: 'refreshed_branch'
description: 'provide a intermediate refreshed branch used for automated tests'
inputs:
base_ref:
description: 'can get with github.event.pull_request.base.ref'
required: true
head_ref:
description: 'can get with github.event.pull_request.head.ref'
required: true
github_token:
description: 'can get with secrets.GITHUB_TOKEN'
required: true
runs:
using: "composite"
steps:
# Define o nome da branch intermediária que será criada e usada pelos testes
- run: echo "branch_name=tests/${{ inputs.head_ref }}_${{ inputs.base_ref }}" >> $GITHUB_ENV
name: Set branch name used for tests
shell: bash
- run: |
echo "refreshed_base_sha=$(cat .git/refs/heads/${{ inputs.base_ref }})" >> $GITHUB_ENV
shell: bash
# Verifica se a branch existe
- run: |
set +e
git checkout ${{ env.branch_name }}
echo "branch_exists=$?" >> $GITHUB_OUTPUT
continue-on-error: true
name: Check if branch used for tests already exists
id: branch-exists
shell: bash
# Cria a branch usada para rodar os testes (nome da branch de trabalho + '_' + nome branch base)
- name: Create refreshed branch
if: ${{steps.branch-exists.outputs.branch_exists == '1'}}
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
branch: 'refs/heads/${{ env.branch_name }}'
sha: '${{ env.refreshed_base_sha }}'
# Faz o merge da head da branch base em cima da nova branch criada no passo anterior a este
- name: Merge branch -> ${{ inputs.head_ref }} into ${{ env.branch_name }}
uses: everlytic/[email protected]
with:
github_token: ${{ inputs.github_token }}
source_ref: ${{ inputs.head_ref }}
target_branch: ${{ env.branch_name }}
commit_message_template: '[Automated] Merged ${{ inputs.github_token }} into target ${{ env.branch_name }}'
# uses: devmasx/merge-branch@master
# with:
# type: now
# from_branch: ${{ inputs.head_ref }}
# target_branch: ${{ env.branch_name }}
# github_token: ${{ inputs.github_token }}