Skip to content

Commit

Permalink
Add workflow to update an existing test site
Browse files Browse the repository at this point in the history
- Runs on PRs targeting `qa/**` branches and which source branch
  starts with `dev-test/`.
- Waits for all the other checks to complete successfully before start.
- Configures a SSH connection to a running AtoM server:
  - The host name must match the branch name. E.g.: for a branch named
    `dev-test/issue-12345-foo-bar` the host must be
    `issue-12345-foo-bar.atom.artefactual.net`.
  - It must accept connections using the DO_SSH_KEY secret.
  - It must have an AtoM instance configured and running.
- The workflow performs the following steps on the existing instance:
  - Stop services (nginx, php7.4-fpm and atom-worker).
  - Fetch latest changes from the PR source branch.
  - Update dependencies (NPM and Composer).
  - Clear Symfony cache.
  - Purge (--demo).
  - Update themes CSS.
  - Start services (allowing more than 3 atom-worker restarts per day).
  • Loading branch information
jraddaoui committed Jun 20, 2021
1 parent 892d070 commit c3e7dc7
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/update-test-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Update test site
on:
pull_request:
branches:
- qa/**
jobs:
update-test-site:
runs-on: ubuntu-20.04
if: ${{ startsWith(github.head_ref, 'dev-test/') }}
steps:
- name: Wait for other checks
uses: lewagon/[email protected]
with:
ref: ${{ github.head_ref }}
wait-interval: 10
running-workflow-name: update-test-site
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$KEY" > ~/.ssh/do.key
chmod 600 ~/.ssh/do.key
cat >>~/.ssh/config <<END
Host do
HostName ${GITHUB_HEAD_REF##*/}.atom.artefactual.net
User root
IdentityFile ~/.ssh/do.key
StrictHostKeyChecking no
END
env:
KEY: ${{ secrets.DO_SSH_KEY }}
- name: Stop services
run: ssh do 'systemctl stop nginx php7.4-fpm atom-worker'
- name: Fetch latest changes
run: |
ssh do 'cd /usr/share/nginx/atom && git fetch \
&& sudo -u www-data git reset --hard \
origin/${{ github.head_ref }}'
- name: Update dependencies
run: |
ssh do 'cd /usr/share/nginx/atom \
&& sudo -u www-data npm install \
&& sudo -u www-data composer install --no-dev'
- name: Clear Symfony cache
run: |
ssh do 'cd /usr/share/nginx/atom \
&& sudo -u www-data php symfony cc'
- name: Purge database
run: |
ssh do 'cd /usr/share/nginx/atom \
&& sudo -u www-data php symfony tools:purge --demo'
- name: Update themes CSS
run: |
ssh do 'cd /usr/share/nginx/atom \
&& sudo -u www-data php symfony tools:build-css'
- name: Start services
run: |
ssh do 'systemctl reset-failed atom-worker \
&& systemctl start atom-worker php7.4-fpm nginx'

0 comments on commit c3e7dc7

Please sign in to comment.