From 80c7b71ad061849d24b042b51bc2195f232abbbc Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Mon, 9 Oct 2023 16:09:07 +0200 Subject: [PATCH] Workflow dependency --- .github/workflows/bbm_build_container.yml | 2 +- .github/workflows/bbm_check_conf.yml | 42 ------------ .../{bbm_deploy_dev.yml => bbm_deploy.yml} | 64 ++++++++++++------- 3 files changed, 41 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/bbm_check_conf.yml rename .github/workflows/{bbm_deploy_dev.yml => bbm_deploy.yml} (61%) diff --git a/.github/workflows/bbm_build_container.yml b/.github/workflows/bbm_build_container.yml index 2adbdf97..c782282d 100644 --- a/.github/workflows/bbm_build_container.yml +++ b/.github/workflows/bbm_build_container.yml @@ -1,5 +1,5 @@ --- -name: bbm-container-build +name: bbm-build-container on: push: diff --git a/.github/workflows/bbm_check_conf.yml b/.github/workflows/bbm_check_conf.yml deleted file mode 100644 index 5f609c40..00000000 --- a/.github/workflows/bbm_check_conf.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -name: bbm-check-conf - -on: - push: - paths: - - ".github/workflows/bbm_check_conf.yml" - - ".github/workflows/deploy.yml" - - "autogen/**" - - "builtbot.tac" - - "common_factories.py" - - "constants.py" - - "docker-compose/**" - - "locks.py" - - "master-**" - - "master.cfg" - - "utils.py" - - "validate_master_cfg.sh" - pull_request: - paths: - - ".github/workflows/bbm_check_conf.yml" - - ".github/workflows/deploy.yml" - - "autogen/**" - - "builtbot.tac" - - "common_factories.py" - - "constants.py" - - "docker-compose/**" - - "locks.py" - - "master-**" - - "master.cfg" - - "utils.py" - - "validate_master_cfg.sh" - -jobs: - build: - runs-on: ubuntu-latest - name: check - - steps: - - uses: actions/checkout@v2 - - name: Check master.cfg files - run: ./validate_master_cfg.sh diff --git a/.github/workflows/bbm_deploy_dev.yml b/.github/workflows/bbm_deploy.yml similarity index 61% rename from .github/workflows/bbm_deploy_dev.yml rename to .github/workflows/bbm_deploy.yml index c12bf0e5..1ea12fd8 100644 --- a/.github/workflows/bbm_deploy_dev.yml +++ b/.github/workflows/bbm_deploy.yml @@ -1,53 +1,69 @@ --- -name: bbm-deploy-dev +name: bbm-deploy on: - workflow_run: - workflows: [bbm-check-conf] - types: [completed] + push: + paths: + - ".github/workflows/bbm_check_conf.yml" + - ".github/workflows/deploy.yml" + - "autogen/**" + - "builtbot.tac" + - "common_factories.py" + - "constants.py" + - "docker-compose/**" + - "locks.py" + - "master-**" + - "master.cfg" + - "utils.py" + - "validate_master_cfg.sh" + pull_request: + paths: + - ".github/workflows/bbm_check_conf.yml" + - ".github/workflows/deploy.yml" + - "autogen/**" + - "builtbot.tac" + - "common_factories.py" + - "constants.py" + - "docker-compose/**" + - "locks.py" + - "master-**" + - "master.cfg" + - "utils.py" + - "validate_master_cfg.sh" jobs: - build: + check: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - name: deploy - steps: + - uses: actions/checkout@v2 + - name: Check master.cfg files + run: ./validate_master_cfg.sh + + deploy: + runs-on: ubuntu-latest + needs: check + if: > + github.ref == 'refs/heads/dev' && + github.repository == 'MariaDB/buildbot' - uses: actions/checkout@v2 - name: prepare - if: > - github.ref == 'refs/heads/dev' && - github.repository == 'MariaDB/buildbot' run: | install -m 600 -D /dev/null ~/.ssh/id_ed25519 install -m 600 -D /dev/null ~/.ssh/known_hosts echo "${{ secrets.SSH_PRIVATE_KEY }}" >~/.ssh/id_ed25519 echo "${{ secrets.SSH_KNOWN_HOSTS }}" >~/.ssh/known_hosts - name: shutdown stack - if: > - github.ref == 'refs/heads/dev' && - github.repository == 'MariaDB/buildbot' run: | ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP }} "if [[ -f /srv/dev/docker-compose/docker-compose.yaml ]]; then docker-compose -f /srv/dev/docker-compose/docker-compose.yaml down; fi" - name: deploy - if: > - github.ref == 'refs/heads/dev' && - github.repository == 'MariaDB/buildbot' run: | rsync -a --progress --delete --exclude-from=rsync.exclude -e "ssh -p ${{ secrets.SERVER_PORT }}" ./ ${{ secrets.USER }}@${{ secrets.SERVER_IP }}:/srv/dev/ ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP }} "cd /srv/dev/docker-compose/ && ./generate-config.py --env=dev" ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP }} "cd /srv/dev/ && ./define_masters.py" ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP }} "cd /srv/dev/docker-compose/ && ln -sf .. buildbot" - name: start stack - if: > - github.ref == 'refs/heads/dev' && - github.repository == 'MariaDB/buildbot' run: | ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP }} "cd /srv/dev/docker-compose && docker-compose pull && docker-compose --env-file .env.dev up -d" - name: clean - if: > - always() && - github.ref == 'refs/heads/dev' && - github.repository == 'MariaDB/buildbot' run: | rm ~/.ssh/id_ed25519