Skip to content

Commit e23e9df

Browse files
committed
feat: add testing workflow
1 parent daa1ecd commit e23e9df

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/workflows/build.yml

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

0 commit comments

Comments
 (0)