-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.46 KB
/
test-and-merge.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
name: Test and merge
on:
push:
branches:
- main
pull_request:
jobs:
tests:
runs-on: macos-12
steps:
- name: Checking out repo...
uses: actions/checkout@v4
with:
submodules: recursive
- name: Installing required packages...
run: brew install openssl curl
- name: Cache Vagrant boxes
uses: actions/cache@v4
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: Generate SSH key if not exist
run: |
if [[ ! -f "~/.ssh/id_rsa" ]]; then
ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
fi;
- name: Show Vagrant version
run: vagrant --version
- name: Run vagrant up
run: vagrant up
- name: test if running
run: |
curl_code=$(curl -Is http://localhost:8000/ | head -1 | grep -o '[0-9][0-9][0-9]');
echo "::set-output name=curl_code::$curl_code";
[[ "$curl_code" == "200" ]] || [[ "$curl_code" == "302" ]];
- name: Run vagrant halt
run: vagrant halt --force
dependabot:
needs: tests
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
# Checking the actor will prevent your Action run failing on non-Dependabot
# PRs but also ensures that it only does work for Dependabot PRs.
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
# This first step will fail if there's no metadata and so the approval
# will not occur.
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Here the PR gets approved.
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Finally, this sets the PR to allow auto-merging for patch and minor
# updates if all checks pass
- name: Enable auto-merge for Dependabot PRs
# if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}