Skip to content

Merge pull request #58 from simlar-0/users-pass-change #49

Merge pull request #58 from simlar-0/users-pass-change

Merge pull request #58 from simlar-0/users-pass-change #49

Workflow file for this run

name: d0018e-deploy
on:
push:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
- 'ansible/**'
- 'README.md'
- '.gitignore'
pull_request:
branches: [ "main" ]
types: [ "closed" ]
paths-ignore:
- 'docs/**'
- 'ansible/**'
- 'README.md'
- '.gitignore'
workflow_dispatch:
jobs:
test:
if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main'
name: Test docker-compose file and containers
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up environment files
run: |
cp .db-example .db
cp .env-example .env
sed -i 's/MYSQL_PASSWORD=""/MYSQL_PASSWORD="${{ secrets.MYSQL_PASSWORD }}"/g' .db
sed -i 's/MYSQL_ROOT_PASSWORD=""/MYSQL_ROOT_PASSWORD="${{ secrets.MYSQL_ROOT_PASSWORD }}"/g' .db
sed -i 's/MYSQL_PASSWORD=""/MYSQL_PASSWORD="${{ secrets.MYSQL_PASSWORD }}"/g' .env
sed -i 's/MYSQL_ROOT_PASSWORD=""/MYSQL_ROOT_PASSWORD="${{ secrets.MYSQL_ROOT_PASSWORD }}"/g' .env
echo "AUTH_KEY=${{ secrets.AUTH_KEY }}" >> .env
- name: Run docker-compose file
run: docker compose up -d
deploy:
if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main'
name: Deploy
needs: test
runs-on: ubuntu-latest
steps:
- name: execute docker-compose on remote host script
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
# extract repo name
REPO_NAME=$(basename ${{ github.repository }})
cd $REPO_NAME
# clean up previous build
docker compose down
cd ..
rm -rf -- $REPO_NAME
git clone ${{ github.server_url }}/${{ github.repository }}
# set up.env and.db files
cd $REPO_NAME
cp .db-example .db
cp .env-example .env
sed -i 's/MYSQL_PASSWORD=""/MYSQL_PASSWORD="${{ secrets.MYSQL_PASSWORD }}"/g' .db
sed -i 's/MYSQL_ROOT_PASSWORD=""/MYSQL_ROOT_PASSWORD="${{ secrets.MYSQL_ROOT_PASSWORD }}"/g' .db
sed -i 's/MYSQL_PASSWORD=""/MYSQL_PASSWORD="${{ secrets.MYSQL_PASSWORD }}"/g' .env
sed -i 's/MYSQL_ROOT_PASSWORD=""/MYSQL_ROOT_PASSWORD="${{ secrets.MYSQL_ROOT_PASSWORD }}"/g' .env
echo "AUTH_KEY=${{ secrets.AUTH_KEY }}" >> .env
docker compose up --build -d