diff --git a/.gitea/workflows/yamllint.yml b/.gitea/workflows/yamllint.yml index 82d28ab..1c22165 100644 --- a/.gitea/workflows/yamllint.yml +++ b/.gitea/workflows/yamllint.yml @@ -1,22 +1,65 @@ -name: YAML Lint +name: CI/CD Pipeline on: push: - branches: [ main, dev ] - pull_request: + branches: [ main ] jobs: - yamllint: + lint: runs-on: docker steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install yamllint + - name: Install linters run: | 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: | - 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 >> ~/.ssh/known_hosts + + - name: Run Ansible deployment + run: | + ansible-playbook \ + -i infrastructure/inventory/hosts \ + infrastructure/playbooks/site.yml