From d8cfb4e1d1c2a32d7de5eec8f9cac06629544230 Mon Sep 17 00:00:00 2001 From: Severin Schols Date: Fri, 18 Oct 2024 10:05:41 +0200 Subject: [PATCH] [ci] run both workflows sequentially --- .github/workflows/deploy.yml | 30 +++++++++++++++++++++ .github/workflows/jekyll-deploy.yml | 42 ----------------------------- 2 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/jekyll-deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..cd067a2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,30 @@ +name: Deploy + +on: + workflow_run: + workflows: ["Create and publish a Docker image"] + branches: [main] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Setup SSH key + shell: bash + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + run: | + mkdir -p ~/.ssh + echo "${SSH_PRIVATE_KEY}" | base64 -d > ${HOME}/.ssh/deploy.id_rsa + chmod 700 ${HOME}/.ssh/deploy.id_rsa + - name: Update Docker container + shell: bash + run: | + ssh -i ${HOME}/.ssh/deploy.id_rsa -o StrictHostKeyChecking=no root@saturn.munichmakerlab.de << EOF + docker pull ghcr.io/munichmakerlab/website:main + systemctl restart docker-website.service + systemctl status docker-website.service + EOF diff --git a/.github/workflows/jekyll-deploy.yml b/.github/workflows/jekyll-deploy.yml deleted file mode 100644 index f5db52f..0000000 --- a/.github/workflows/jekyll-deploy.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Deploy - -on: - push: - branches: - - master - - main - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Setup Ruby - uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0 - with: - ruby-version: '3.1' # Not needed with a .ruby-version file - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - cache-version: 0 # Increment this number if you need to re-download cached gems - - name: Build with Jekyll - # Outputs to the './_site' directory by default - run: bundle exec jekyll build - env: - JEKYLL_ENV: production - - name: Create SSH key - shell: bash - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - run: | - mkdir -p ~/.ssh - echo "${SSH_PRIVATE_KEY}" | base64 -d > ${HOME}/.ssh/deploy.id_rsa - chmod 700 ${HOME}/.ssh/deploy.id_rsa - - name: Update Docker container - shell: bash - run: | - ssh -i ${HOME}/.ssh/deploy.id_rsa -o StrictHostKeyChecking=no root@saturn.munichmakerlab.de << EOF - docker pull ghcr.io/munichmakerlab/website:main - systemctl restart docker-website.service - systemctl status docker-website.service - EOF