Skip to content

Commit da518cb

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

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

.github/workflows/build.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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: Run docker container
15+
run: docker compose up -d
16+
17+
- name: Check docker logs
18+
run: |
19+
docker ps
20+
docker compose logs web
21+
22+
- name: Test if service is reachable
23+
run: |
24+
sleep 30
25+
curl -v -s --retry 10 --retry-connrefused http://localhost:8000/
26+
27+
- name: Report error to Sentry
28+
if: failure()
29+
run: |
30+
curl -sL https://sentry.io/get-cli/ | bash
31+
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
32+
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
33+
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
34+
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

config/environments/development.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
# Divio Cloud config
7878
config.hosts = [
79-
/.*\.aldryn\.io/
79+
/.*\.aldryn\.io/,
80+
'0.0.0.0',
8081
]
8182
end

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)