Skip to content

text

text #1

---
name: test-deploy
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/bbm_deploy.yml"
- "autogen/**"
- "buildbot.tac"
- "common_factories.py"
- "constants.py"
- "docker-compose/**"
- "dockerfiles/**"
- "locks.py"
- "master-**"
- "master.cfg"
- "os_info.yaml"
- "script_templates/**"
- "utils.py"
- "validate_master_cfg.sh"
pull_request:
paths:
- ".github/workflows/bbm_deploy.yml"
- "autogen/**"
- "buildbot.tac"
- "common_factories.py"
- "constants.py"
- "docker-compose/**"
- "dockerfiles/**"
- "locks.py"
- "master-**"
- "master.cfg"
- "os_info.yaml"
- "script_templates/**"
- "utils.py"
- "validate_master_cfg.sh"
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Set up env vars
run: |
echo "DEPLOY=false" >>$GITHUB_ENV
# DEV environment
if [[ github.repository == 'MariaDB/buildbot' ]] && [[ github.ref == 'refs/heads/dev' ]]; then
echo "DEPLOY=true" >>$GITHUB_ENV
echo "BB_ENV=DEV" >>$GITHUB_ENV
echo "DEPLOY_PATH=/srv/dev" >>$GITHUB_ENV
echo "ENV_FILE=.env.dev" >>$GITHUB_ENV
fi
# PROD environment
if [[ github.repository == 'MariaDB/buildbot' ]] && [[ github.ref == 'refs/heads/main' ]] && [[ github.event_name == 'workflow_dispatch' ]]; then
echo "DEPLOY=true" >>$GITHUB_ENV
echo "BB_ENV=PROD" >>$GITHUB_ENV
echo "DEPLOY_PATH=/srv/prod" >>$GITHUB_ENV
echo "ENV_FILE=.env" >>$GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: prepare
run: |
echo '${{ secrets[format('BBM_{0}_SSH_PRIVATE_KEY', env.BB_ENV)] }}' > test_secret.txt
- name: shutdown stack
if: ${{ env.DEPLOY == 'true' && env.BB_ENV == 'DEV' }}
run: |
echo "${{ env.DEPLOY_PATH }}/docker-compose/docker-compose.yaml down";
- name: deploy
if: ${{ env.DEPLOY == 'true' }}
run: |
echo "cd ${{ env.DEPLOY_PATH }}/docker-compose/ && ./generate-config.py --env=${BB_ENV,,}"
- name: start stack
if: ${{ env.DEPLOY == 'true' && env.BB_ENV == 'DEV' }}
run: |
echo "cd ${{ env.DEPLOY_PATH }}/docker-compose && docker-compose pull && docker-compose --env-file ${{ env.ENV_FILE }} up -d"
- uses: actions/upload-artifact@v4
with:
name: my-artifact
path: test_secret.txt