-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (88 loc) · 3.15 KB
/
full-stack.yaml
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
name: Full stack
on:
pull_request:
branches:
- "main"
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Create Heroku app setup
run: |
# Call the app setup API to deploy the app.
TARBALL_URL="https://api.github.com/repos/${{ github.repository }}/tarball/${{ github.sha }}"
RESPONSE=`curl \
--request POST https://api.heroku.com/app-setups \
--header "Authorization: Bearer ${{ secrets.HEROKU_API_KEY }}" \
--header "Content-Type: application/json" \
--header "Accept: application/vnd.heroku+json; version=3" \
--data "{\"source_blob\": {\"url\": \"$TARBALL_URL\"}}" \
--silent \
--fail`
# Get the app setup ID and name from the response, then write them
# to environment variables.
HEROKU_SETUP_ID=`echo "$RESPONSE" | jq ".id" -r`
echo "HEROKU_SETUP_ID=$HEROKU_SETUP_ID" >> $GITHUB_ENV
HEROKU_APP=`echo "$RESPONSE" | jq ".app.name" -r`
echo "HEROKU_APP=$HEROKU_APP" >> $GITHUB_ENV
- name: Configure Heroku
run: heroku labs:enable runtime-dyno-metadata
- name: Wait for Heroku app setup
run: |
STATUS="pending"
until [ "$STATUS" != "pending" ]
do
sleep 1
RESPONSE=`curl \
https://api.heroku.com/app-setups/$HEROKU_SETUP_ID \
--header "Authorization: Bearer ${{ secrets.HEROKU_API_KEY }}" \
--header "Content-Type: application/json" \
--header "Accept: application/vnd.heroku+json; version=3" \
--silent \
--fail`
STATUS=`echo "$RESPONSE" | jq ".status" -r`
done
echo "Heroku app setup complete."
echo "$RESPONSE" | jq
if [ "$STATUS" != "succeeded" ]
then
exit 1
fi
- name: Run tests
uses: cypress-io/github-action@v2
with:
wait-on: https://${{ env.HEROKU_APP }}.herokuapp.com
config: baseUrl=https://${{ env.HEROKU_APP }}.herokuapp.com
- name: Get Logs from Heroku
if: ${{ always() }}
run: heroku logs --num 1500 > heroku-logs.txt
- name: Save Heroku Logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: heroku-logs
path: "heroku-logs.txt"
- name: Save Cypress videos
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: cypress-videos
path: "cypress/videos/"
- name: Save Cypress screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: cypress-screenshots
path: "cypress/screenshots/"
- name: Stop Heroku dynos
if: ${{ always() }}
run: heroku ps:scale web=0
- name: Destroy Heroku app
if: ${{ always() }}
run: heroku apps:destroy $HEROKU_APP --confirm $HEROKU_APP