ci/cd
This commit is contained in:
@@ -1,22 +1,65 @@
|
|||||||
name: YAML Lint
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, dev ]
|
branches: [ main ]
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
yamllint:
|
lint:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install yamllint
|
- name: Install linters
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache python3 py3-pip
|
apk add --no-cache python3 py3-pip
|
||||||
pip install --no-cache-dir yamllint
|
pip install yamllint ansible-lint
|
||||||
|
|
||||||
- name: Run yamllint
|
- name: YAML lint
|
||||||
|
run: yamllint .
|
||||||
|
|
||||||
|
- name: Ansible lint
|
||||||
|
run: ansible-lint infrastructure/playbooks
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
needs: lint
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Gitea Registry
|
||||||
run: |
|
run: |
|
||||||
yamllint .
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
||||||
|
docker login dns.s-martika.com \
|
||||||
|
-u "${{ secrets.REGISTRY_USER }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
-t dns.s-martika.com/smartika/snake:latest \
|
||||||
|
frontend/
|
||||||
|
|
||||||
|
- name: Push Docker image
|
||||||
|
run: |
|
||||||
|
docker push dns.s-martika.com/smartika/snake:latest
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: docker
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup SSH
|
||||||
|
run: |
|
||||||
|
apk add --no-cache openssh ansible
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H <SERVER_IP> >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Run Ansible deployment
|
||||||
|
run: |
|
||||||
|
ansible-playbook \
|
||||||
|
-i infrastructure/inventory/hosts \
|
||||||
|
infrastructure/playbooks/site.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user