Skip to content

Commit 4ee59a8

Browse files
Update deploy.yml
1 parent ef7c8c8 commit 4ee59a8

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI/CD for PostgreSQL Docker
1+
name: CI/CD for PostgreSQL Docker - Build, Push, and Deploy
22

33
on:
44
workflow_dispatch:
@@ -8,89 +8,77 @@ on:
88
required: true
99
default: 'development'
1010
postgres_version:
11-
description: 'Postgres Version'
11+
description: 'PostgreSQL Version'
1212
required: true
13-
default: '17'
13+
default: '17.0'
1414

1515
jobs:
1616
build-and-push:
17-
name: Build and Push Docker Images for PostgreSQL
17+
name: Build and Push PostgreSQL Docker Image
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
# Checkout Postgres Docker repository into a specific directory
2221
- name: Checkout Postgres Repository
2322
uses: actions/checkout@v3
2423
with:
2524
repository: trplgit/postgres
2625
token: ${{ secrets.GITHUB_TOKEN }}
27-
path: postgres # Checkout into the 'postgres' directory
26+
path: postgres
2827

29-
# Set up Docker buildx
3028
- name: Set up Docker
3129
uses: docker/setup-buildx-action@v2
3230
with:
3331
version: latest
3432

35-
# Log in to Azure Container Registry
3633
- name: Log in to Azure Container Registry
3734
uses: azure/docker-login@v1
3835
with:
3936
login-server: ${{ vars.ACR_NAME }}.azurecr.io
4037
username: ${{ vars.ACR_USERNAME }}
4138
password: ${{ secrets.ACR_PASSWORD }}
4239

43-
# Build and Push Postgres Docker Image for PostgreSQL 17
4440
- name: Build and Push Postgres Docker Image
4541
run: |
4642
docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21
4743
docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17
4844
4945
deploy:
50-
name: Deploy PostgreSQL to Linux VM
46+
name: Deploy PostgreSQL Docker Container to Linux VM
5147
runs-on: ubuntu-latest
5248
needs: build-and-push
5349

5450
steps:
55-
# Install OpenVPN
5651
- name: Install OpenVPN
5752
run: sudo apt-get install -y openvpn
5853

59-
# Prepare VPN files
6054
- name: Prepare VPN Files
6155
run: |
6256
echo "${{ secrets.VPN_PKCS12_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation.p12
6357
echo "${{ secrets.VPN_TLS_KEY_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation-tls.key
6458
65-
# Connect to VPN
6659
- name: Connect to VPN
6760
run: |
6861
echo "${{ secrets.VPN_CONFIG_FILE }}" > vpn-config.ovpn
6962
echo -e "${{ vars.VPN_USERNAME }}\n${{ secrets.VPN_PASSWORD }}" > vpn-credentials.txt
7063
sudo openvpn --config vpn-config.ovpn --auth-user-pass vpn-credentials.txt --daemon
7164
72-
# Wait for VPN connection
7365
- name: Wait for VPN Connection
7466
run: sleep 15
7567

76-
# Verify VPN connection
7768
- name: Verify VPN Connection
7869
run: |
7970
ifconfig | grep tun || (echo "VPN connection failed" && exit 1)
8071
81-
# Add user to Docker group to allow Docker commands without sudo
8272
- name: Add user to Docker group
8373
run: |
8474
sudo usermod -aG docker $USER
8575
newgrp docker || true
8676
87-
# Create Docker network if not exists
8877
- name: Create Docker Network if not exists
8978
run: |
9079
echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker network create odoo-postgres-network || echo "Network already exists"
9180
92-
# Deploy Postgres Docker container to VM
93-
- name: Deploy Postgres Docker Container to VM
81+
- name: Deploy PostgreSQL Docker Container to VM
9482
uses: appleboy/ssh-action@v0.1.6
9583
with:
9684
host: ${{ vars.LINUX_VM_HOST_DEVELOPMENT }}
@@ -106,7 +94,6 @@ jobs:
10694
# Run Postgres container (PostgreSQL 17)
10795
echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker run -d --restart always --name postgres-container --network=odoo-postgres-network -e POSTGRES_PASSWORD=mysecretpassword -p 5433:5433 ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17
10896
109-
# Cleanup VPN credentials
11097
- name: Cleanup VPN Credentials
11198
run: |
11299
rm -f vpn-config.ovpn vpn-credentials.txt

0 commit comments

Comments
 (0)