Skip to content

Commit

Permalink
feat: add testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalAngel committed Apr 24, 2024
1 parent 2825a84 commit 8c9219b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build template

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build docker image
run: docker compose build

- name: Run docker container
run: docker compose up -d

- name: Check docker logs
run: |
docker compose logs web
- name: Test if service is reachable
run: |
sleep 30
curl -v -s --retry 10 --retry-connrefused http://localhost:8000/
- name: Report error to Sentry
if: failure()
run: |
curl -sL https://sentry.io/get-cli/ | bash
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy template

on:
# push:
schedule:
- cron: "20 16 * * *"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install divio-cli
- name: Deploy to Divio
run: |
divio login ${{ secrets.DIVIO_TOKEN }}
divio app deploy test --remote-id ${{ secrets.DIVIO_WEBSITE_ID }} --build-mode FORCE
- name: Test if website is reachable
run: |
curl -v -s --retry 10 --retry-connrefused ${{ secrets.WEBSITE_URL }}
- name: Report error to Sentry
if: failure()
run: |
curl -sL https://sentry.io/get-cli/ | bash
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ USER rails:rails

# Start the server by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/rails", "server", "-p", "80", "-b", "0.0.0.0"]
CMD ["bundle", "exec", "rais", "server", "-p", "80", "-b", "0.0.0.0"]
3 changes: 2 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

# Divio Cloud config
config.hosts = [
/.*\.aldryn\.io/
/.*\.aldryn\.io/,
'localhost:8000',
]
end
20 changes: 10 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ version: "3"
services:
web:
build: .
command: ./bin/rails server -e development -b 0.0.0.0 -p 80
command: bundle exec rails server -p 8000 -b 0.0.0.0
volumes:
- .:/rails
ports:
- "8000:80"
depends_on:
- db
- "8000:8000"
# depends_on:
# - db
environment:
SECRET_KEY_BASE: secret

db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
# db:
# image: postgres
# volumes:
# - ./tmp/db:/var/lib/postgresql/data
# environment:
# POSTGRES_PASSWORD: password

0 comments on commit 8c9219b

Please sign in to comment.