[ci/cd] feat: added linting and deployment workflow
This commit is contained in:
parent
6c810044fb
commit
8d01a07f3f
1 changed files with 70 additions and 0 deletions
70
.gitea/workflow/deployment.yaml
Normal file
70
.gitea/workflow/deployment.yaml
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
|
||||
# generic
|
||||
name: "Linting and Deployment"
|
||||
on: # yamllint disable-line rule:truthy
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
# jobs
|
||||
jobs:
|
||||
|
||||
# ansible linting
|
||||
Linting:
|
||||
runs-on: "ubuntu-latest"
|
||||
container:
|
||||
image: "cr.simoncor.net/siempie/ansible-deployment:latest"
|
||||
credentials:
|
||||
username: "${{ vars.REGISTER_USERNAME }}"
|
||||
password: "${{ vars.REGISTER_PASSWORD }}"
|
||||
|
||||
# steps
|
||||
steps:
|
||||
|
||||
# checkout code
|
||||
- name: "Clone repo"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
# setup vault key
|
||||
- name: "Setup Vault Key"
|
||||
run: |
|
||||
echo ${{ secrets.VAULT_KEY }} >> secret.key
|
||||
|
||||
# run ansible linter
|
||||
- name: "Run Ansible Lint"
|
||||
run: |
|
||||
ansible-lint -c .
|
||||
|
||||
|
||||
# ansible deployment
|
||||
Deployment:
|
||||
runs-on: "ubuntu-latest"
|
||||
needs: "Linting"
|
||||
|
||||
# steps
|
||||
steps:
|
||||
|
||||
# ansible deployment
|
||||
- name: "Ansible deployment"
|
||||
uses: "appleboy/ssh-action@v1.2.0"
|
||||
with:
|
||||
|
||||
# bastion
|
||||
proxy_host: "bastion.simoncor.net"
|
||||
proxy_port: "22"
|
||||
proxy_username: "${{ secrets.USERNAME }}"
|
||||
proxy_key: "${{ secrets.SSHKEY }}"
|
||||
|
||||
# ansible server
|
||||
host: "ansible.siempie.internal"
|
||||
port: "22"
|
||||
username: "${{ secrets.USERNAME }}"
|
||||
key: "${{ secrets.SSHKEY }}"
|
||||
|
||||
# execute commands
|
||||
script: |
|
||||
sudo /usr/bin/git -C /etc/ansible/roles/common reset --hard HEAD
|
||||
sudo /usr/bin/git -C /etc/ansible/roles/common clean -fd
|
||||
sudo /usr/bin/git -C /etc/ansible/roles/common fetch --quiet
|
||||
sudo /usr/bin/git -C /etc/ansible/roles/common pull origin main --quiet
|
||||
Loading…
Add table
Add a link
Reference in a new issue