-
Notifications
You must be signed in to change notification settings - Fork 10
Creation of a github action workflow
Stanislav Kutasevits edited this page Dec 1, 2022
·
16 revisions
- Go to Actions - https://github.com/OS2Forms/os2forms8/actions
- Depending on if you already have an action or creating a new one, you will get a different screen:
- If there are previous actions, click on Click on New workflow
- Click Set up a workflow yourself:
- Add the content of your workflow, for example like this:
name: Deploy release to test.os2forms.dk https://github.com/OS2Forms/os2forms8/actions/workflows/deploy-release-to-test.yml
on:
release:
types: [published]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
whoami
sh /var/www/test.os2forms.dk/private/os2forms_init/rebuild_installation.sh
This workflow will react to a new release being published and execute the scripts after it.
The script executed is located on the server in [doc root]/private/os2forms_init/rebuild_installation.sh:
#! /bin/bash
cd /var/www/test.os2forms.dk
drush sql-dump | gzip > /var/www/test.os2forms.dk/private/os2forms_init/db_dumps/test.os2forms.dk_latest.sql.gz
git pull
rm composer.lock
composer install
drush cr
- Create the user for the github action
- Create the keys for the user
- Make sure SSH is accessible
- Login with the user at least once to make sure there is no prompt
- Add rebuild_installation.sh script to the server
- Test rebuild_installation.sh and and make sure that it is working
The script will be triggered every time a new release has been created. The execution details can be seen here: https://github.com/OS2Forms/os2forms8/actions/workflows/deploy-release-to-test.yml
- In order to make the ssh connection work, we need to add credentials/secrets to github (only available if you have admin rights):
- https://github.com/OS2Forms/os2forms8/settings/secrets/actions
- Create each of the following key pairs.
HOST: 193.84.27.193
PORT: 22
USERNAME: [server username]
KEY: [server user private key]
Test by creating new release
For debugging go the the script that was executet. You can se each "run".
- https://github.com/OS2Forms/os2forms8/actions/workflows/deploy-release-to-test.yml
- Click on the one you want to debug. Example: https://github.com/OS2Forms/os2forms8/actions/runs/3564610566
- Click on the green build button. And drill down into each tasks output.