Skip to content

gh actions test

gh actions test #2

Workflow file for this run

name: CI
on: [push, pull_request, workflow_call]
jobs:
deploy:
name: "Deploy to production"
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Clone repository
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
script_stop: false
script: |
cd ~/repos
if [ ! -d "${{ github.event.repository.name }}" ]; then
git clone https://github.com/arg-tech/${{ github.event.repository.name }}.git
fi
- name: Pull latest code
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
script_stop: false
script: |
cd ~/repos/${{ github.event.repository.name }}
git checkout ${{ github.ref_name }}
git fetch
git reset --hard HEAD
git merge '@{u}'
- name: Create secrets
if: ${{ env.ARE_SECRETS_PRESENT == 'true' }}
env:
ARE_SECRETS_PRESENT: ${{ secrets.PRODUCTION_PROJECT_SECRETS != '' }}
SECRETS: ${{ secrets.PRODUCTION_PROJECT_SECRETS }}
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
envs: SECRETS
script_stop: false
script: |
cd ~/repos/${{ github.event.repository.name }}
[[ -z "$SECRETS" ]] && { echo "No secrets specified, skipping step" ; exit 0; }
mkdir -p .secrets && cd "$_"
i=1
while secret=$(echo "$SECRETS" | cut -d "&" -f $i) ; [ -n "$secret" ] ;do
i=$((i+1))
key=$(echo "$secret" | cut -d "=" -f 1)
value=$(echo "$secret" | cut -d "=" -f 2)
echo "$value" > "$key".txt
break
done
- name: Start container
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
script_stop: false
script: |
cd ~/repos/${{ github.event.repository.name }}
docker compose up -d --build