Skip to content

Commit ad14950

Browse files
committed
Using env directly
1 parent 1093649 commit ad14950

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,18 @@ jobs:
116116
exit 1
117117
fi
118118
119-
- name: Prepare setup-dc.sh script
119+
- name: Prepare environment configuration
120120
run: |
121-
# Replace placeholders in setup-dc.sh
122-
sed -i "s/{{IP_ADDRESS}}/${{ env.ip }}/g" setup-dc.sh
123-
sed -i "s/{{PORT}}/${{ env.MAUTIC_PORT }}/g" setup-dc.sh
124-
sed -i "s/{{EMAIL_ADDRESS}}/${{ env.EMAIL_ADDRESS }}/g" setup-dc.sh
125-
sed -i "s/{{MAUTIC_PASSWORD}}/${{ secrets.MAUTIC_PASSWORD }}/g" setup-dc.sh
126-
if [ ! -z "${{ env.DOMAIN }}" ]; then
127-
sed -i "s/{{DOMAIN_NAME}}/${{ env.DOMAIN }}/g" setup-dc.sh
121+
# Create a deployment .env file with all required variables
122+
cp .env deploy.env
123+
echo "EMAIL_ADDRESS=${{ vars.EMAIL_ADDRESS }}" >> deploy.env
124+
echo "MAUTIC_PASSWORD=${{ secrets.MAUTIC_PASSWORD }}" >> deploy.env
125+
echo "IP_ADDRESS=${{ env.ip }}" >> deploy.env
126+
echo "PORT=${{ env.MAUTIC_PORT }}" >> deploy.env
127+
if [ ! -z "${{ vars.DOMAIN }}" ]; then
128+
echo "DOMAIN_NAME=${{ vars.DOMAIN }}" >> deploy.env
128129
fi
129-
cat setup-dc.sh # debug
130+
cat deploy.env # debug
130131
env:
131132
EMAIL_ADDRESS: ${{ vars.EMAIL_ADDRESS }}
132133
DOMAIN: ${{ vars.DOMAIN }}

setup-dc.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
cd /var/www
2+
3+
# Load environment variables from deploy.env (created by GitHub Actions)
4+
if [ -f "/var/www/deploy.env" ]; then
5+
source /var/www/deploy.env
6+
echo "## Environment variables loaded from deploy.env"
7+
else
8+
echo "## Warning: deploy.env not found, using defaults"
9+
fi
10+
211
docker compose build
312
docker compose up -d db --wait && docker compose up -d mautic_web --wait
413

@@ -32,15 +41,10 @@ else
3241
echo "Container $MAUTIC_WORKER_CONTAINER does not exist or is not running."
3342
fi
3443
echo "## Installing Mautic..."
35-
docker compose exec -T -u www-data -w /var/www/html mautic_web php ./bin/console mautic:install --force --admin_email {{EMAIL_ADDRESS}} --admin_password {{MAUTIC_PASSWORD}} http://{{IP_ADDRESS}}:{{PORT}}
44+
docker compose exec -T -u www-data -w /var/www/html mautic_web php ./bin/console mautic:install --force --admin_email "${EMAIL_ADDRESS}" --admin_password "${MAUTIC_PASSWORD}" "http://${IP_ADDRESS}:${PORT}"
3645

3746
echo "## Installing custom themes and plugins..."
3847

39-
# Load environment variables
40-
if [ -f "/var/www/.env" ]; then
41-
source /var/www/.env
42-
fi
43-
4448
# Install themes
4549
if [ ! -z "$MAUTIC_THEMES" ]; then
4650
echo "### Processing themes..."
@@ -77,10 +81,11 @@ fi
7781
echo "## Starting all the containers"
7882
docker compose up -d
7983

80-
DOMAIN="{{DOMAIN_NAME}}"
84+
# Use DOMAIN_NAME from environment variables
85+
DOMAIN="$DOMAIN_NAME"
8186

82-
if [[ "$DOMAIN" == *"DOMAIN_NAME"* ]]; then
83-
echo "The DOMAIN variable is not set yet."
87+
if [ -z "$DOMAIN" ]; then
88+
echo "The DOMAIN_NAME variable is not set yet."
8489
exit 0
8590
fi
8691

@@ -125,7 +130,7 @@ fi
125130
echo "## Configuring Let's Encrypt for $DOMAIN..."
126131

127132
# Use Certbot with the Nginx plugin to obtain and install a certificate
128-
certbot --nginx -d $DOMAIN --non-interactive --agree-tos -m {{EMAIL_ADDRESS}}
133+
certbot --nginx -d $DOMAIN --non-interactive --agree-tos -m "$EMAIL_ADDRESS"
129134

130135
# Nginx will be reloaded automatically by Certbot after obtaining the certificate
131136
echo "## Let's Encrypt configured for $DOMAIN"

0 commit comments

Comments
 (0)