Skip to content

Commit 6518a89

Browse files
committed
adding github workflow
1 parent b063347 commit 6518a89

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker Build and Run Test
2+
3+
on:
4+
push:
5+
branches:
6+
- 2.x # Or any branch you want to trigger the workflow
7+
- dev
8+
pull_request:
9+
branches:
10+
- 2.x # Or any branch you want to trigger the workflow
11+
- dev
12+
13+
jobs:
14+
build-and-test:
15+
runs-on: ubuntu-latest
16+
17+
services:
18+
# You can define services that need to be running while testing
19+
# For example, if your app relies on a database, you could define it here
20+
# db:
21+
# image: postgres:latest
22+
# ports:
23+
# - 5432:5432
24+
25+
steps:
26+
- name: Check out the repository
27+
uses: actions/checkout@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v2
31+
32+
- name: Set up Docker Compose
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y docker-compose
36+
37+
- name: Create a sealog-files directory
38+
run: |
39+
sudo mkdir -p /opt/sealog-server/sealog-files
40+
41+
- name: Generate a secret key
42+
id: generate-secret
43+
run: |
44+
# Generate a random secret key using openssl
45+
SECRET_KEY=$(openssl rand -base64 32)
46+
echo "Generated secret key: $SECRET_KEY"
47+
# Save the secret key for later steps
48+
echo "SECRET_KEY=$SECRET_KEY" >> $GITHUB_ENV
49+
50+
- name: Modify docker-compose.yml (example)
51+
run: |
52+
cp docker-compose.yml.dist docker-compose.yml
53+
54+
sed -i "s|<SECRET_TOKEN>|${{ secrets.SECRET_KEY }}|g" docker-compose.yml
55+
56+
- name: Build and Run Docker Compose
57+
run: |
58+
docker-compose -f docker-compose.yml up -d --build
59+
# Optionally, add a wait or check to ensure the container is running
60+
docker-compose ps
61+
62+
- name: Run tests or validation (if applicable)
63+
run: |
64+
# You can run any tests or health checks here, e.g., using curl or a test script.
65+
# Example for a web server test:
66+
curl -f http://localhost:8000 || exit 1
67+
68+
- name: Tear down Docker Compose
69+
run: |
70+
docker-compose down

0 commit comments

Comments
 (0)