forked from R-OV-NL/GTFS-RT
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (71 loc) · 2.56 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Deploy to Production
on:
push:
branches:
- main
pull_request:
types:
- closed
branches:
- main
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.SHARED_PAT }}
submodules: recursive
- name: Build and start services
run: |
docker compose -f docker-compose.test.yml up -d database
sleep 10 # Adjust sleep time as needed to allow services to start
- name: Wait for database to be ready
run: |
until docker compose -f docker-compose.test.yml exec -T database pg_isready -U postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
- name: Start app service
run: docker compose -f docker-compose.test.yml up --force-recreate --build --exit-code-from app app --remove-orphans
- name: Clean up
if: always()
run: docker compose -f docker-compose.test.yml down
build_and_push:
name: Build and push to ACR
needs: build_and_test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.SHARED_PAT }}
submodules: recursive
- name: Log in to Azure Container Registry
run: |
echo "${{ secrets.AZURE_PASSWORD }}" | docker login "${{ secrets.ACR_REGISTRY }}" --username "${{ secrets.AZURE_APP_ID }}" --password-stdin
- name: Set version
run: echo "VERSION=${{ github.run_number }}" >> $GITHUB_ENV
- name: Build Docker Image with both tags
run: |
docker build -t ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:latest \
-t ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:${{ env.VERSION }} \
-f Dockerfile .
- name: Push Docker Image to ACR with both tags
run: |
docker push ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:latest
docker push ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:${{ env.VERSION }}
deploy:
name: Deploy to Production
if: github.event.pull_request.merged == true || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Run compose script in Deployment repository.
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Deploy Docker Images
repo: infoplaza-mobility/Deploy
token: ${{ secrets.SHARED_PAT }}
ref: main