Skip to content

Commit

Permalink
Run Ansible on Actions runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Tina-otoge committed Apr 11, 2024
1 parent 87678ad commit fd9787c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Deploy

on:
push:
branches:
Expand All @@ -8,20 +10,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Run deploy job
uses: appleboy/ssh-action@v1.0.3
- name: Clone Ansible
uses: actions/checkout@v2
with:
host: ${{ secrets.DEPLOY_RUNNER }}
username: ${{ secrets.DEPLOY_RUNNER_USER }}
key: ${{ secrets.DEPLOY_RUNNER_KEY }}
script_stop: true
script: |
dir=$(mktemp -d)
git clone https://github.com/Tina-otoge/infra.git $dir --depth 1 -b master --single-branch
cd $dir
pwd
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
ansible-playbook -l ${{ secrets.DEPLOY_HOST }} playbooks/deploy/mechadon.yml -e "deploy_version=${{ github.sha }}" -e "deploy_user=${{ secrets.DEPLOY_USER }}"
rm -rf $dir
repository: Tina-otoge/infra
ref: master
- name: Install dependencies
run: |
pip install -U pip
pip install -r requirements.txt
- name: Save SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Run Ansible
run: |
ansible-playbook -l ${{ secrets.DEPLOY_HOST }} playbooks/deploy/mechadon.yml -e "deploy_version=${{ github.sha }}" -e "deploy_user=${{ secrets.DEPLOY_USER }}" -u ${{ secrets.DEPLOY_USER }}

0 comments on commit fd9787c

Please sign in to comment.