Skip to content

Commit 879a7a8

Browse files
committed
feat: add testing workflow
1 parent 2825a84 commit 879a7a8

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed

.github/workflows/build.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build template
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Build docker image
12+
run: docker compose build
13+
14+
- name: Check docker logs
15+
run: docker compose logs
16+
17+
- name: Run docker container
18+
run: docker compose up -d
19+
20+
- name: Check docker logs
21+
run: |
22+
docker ps
23+
docker compose logs
24+
curl -v http://localhost:8000/
25+
26+
- name: Test if service is reachable
27+
run: |
28+
sleep 30
29+
curl -v -s --retry 10 --retry-connrefused http://localhost:8000/
30+
31+
- name: Report error to Sentry
32+
if: failure()
33+
run: |
34+
curl -sL https://sentry.io/get-cli/ | bash
35+
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
36+
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
37+
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
38+
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error

.github/workflows/deploy.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy template
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: "20 16 * * *"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.12"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install divio-cli
23+
24+
- name: Deploy to Divio
25+
run: |
26+
divio login ${{ secrets.DIVIO_TOKEN }}
27+
divio app deploy test --remote-id ${{ secrets.DIVIO_WEBSITE_ID }} --build-mode FORCE
28+
29+
- name: Test if website is reachable
30+
run: |
31+
curl -v -s --retry 10 --retry-connrefused ${{ secrets.WEBSITE_URL }}
32+
33+
- name: Report error to Sentry
34+
if: failure()
35+
run: |
36+
curl -sL https://sentry.io/get-cli/ | bash
37+
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
38+
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
39+
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
40+
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3"
33
services:
44
web:
55
build: .
6-
command: ./bin/rails server -e development -b 0.0.0.0 -p 80
6+
command: ./bin/rails server -e development -p 80 -b 0.0.0.0
77
volumes:
88
- .:/rails
99
ports:

0 commit comments

Comments
 (0)