Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ansible-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Ansible Deployment

on:
push:
branches: [ main, master ]
paths:
- 'ansible/**'
- '.github/workflows/ansible-deploy.yml'
pull_request:
branches: [ main, master ]
paths:
- 'ansible/**'

jobs:
lint:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
pip install ansible ansible-lint

- name: Run ansible-lint
run: |
cd ansible
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > ./.vault_pass
ansible-lint playbooks/*.yml -x no-relative-paths

deploy:
runs-on: self-hosted
needs: lint
steps:
- uses: actions/checkout@v4

- name: Deploy with Ansible
run: |
cd ansible
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > /tmp/vault_pass
ansible-playbook playbooks/deploy.yml \
--vault-password-file /tmp/vault_pass \
--tags "app_deploy"
rm /tmp/vault_pass

- name: Verify Deployment
run: |
sleep 10 # Wait for app to start
curl -f http://${{ secrets.VM_HOST }}:8000 || exit 1
curl -f http://${{ secrets.VM_HOST }}:8000/health || exit 1
72 changes: 72 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Go CI

on:
pull_request:
branches: [ master ]
paths:
- 'app_go/**'
- '.github/workflows/go-ci.yml'
- '!app_go/docs/**'
- '!app_go/README.md'
- '!**.gitignore'
push:
paths:
- 'app_go/**'
- '.github/workflows/go-ci.yml'
- '!app_go/docs/**'
- '!app_go/README.md'
- '!**.gitignore'


jobs:
test:
name: Verify go app
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_go
steps:
- uses: actions/checkout@v4

- name: Set up go
uses: actions/setup-go@v4
with:
go-version: '1.25'
cache: true
cache-dependency-path: 'app_go/go.sum'

- name: Lint
uses: golangci/golangci-lint-action@v9
with:
working-directory: ./app_go

- name: Install dependencies
run: go mod download

- name: Test with Coverage
run: |
CGO_ENABLED=0 go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

docker:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./app_go
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/infoservice:go-latest
${{ secrets.DOCKER_USERNAME }}/infoservice:go-${{ github.event.pull_request.number }}.1.0

74 changes: 74 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Python CI

on:
pull_request:
branches: [ master ]
paths:
- 'app_python/**'
- '.github/workflows/python-ci.yml'
- '!app_python/docs/**'
- '!app_python/README.md'
- '!**.gitignore'
push:
paths:
- 'app_python/**'
- '.github/workflows/python-ci.yml'
- '!app_python/docs/**'
- '!app_python/README.md'
- '!**.gitignore'

jobs:
test:
name: Verify python app
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'requirements.txt'

# - name: Run Snyk
# uses: snyk/actions/python-3.10@master
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# args: --severity-threshold=high

- name: Lint
run: |
pip install flake8
flake8 infoservice/infoservice.py

- name: Install dependencies
run: |
pip install -r requirements.txt

- name: Test with coverage
run: pytest

docker:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./app_python
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/infoservice:python-latest
${{ secrets.DOCKER_USERNAME }}/infoservice:python-${{ github.event.pull_request.number }}.1.0
40 changes: 40 additions & 0 deletions .github/workflows/terraform-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Terraform CI

on:
pull_request:
branches: [ master ]
paths:
- 'terraform/**'

jobs:
validate:
name: Validate terraform configuration
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup terraform
uses: hashicorp/setup-terraform@v3

- name: Check formatting
run: terraform fmt -check

- name: Initialize terraform
run: terraform init

- name: Validate syntax
run: terraform validate

- name: Setup terraform linter
uses: terraform-linters/setup-tflint@v6

- name: Lint terraform
run: tflint

# - name: GitHub Integration
# run: |
# cd ./terraform
# export GITHUB_TOKEN=${{ secrets.TERRAFORM_GITHUB_TOKEN }}
# terraform import github_repository.course_repo DevOps-Core-Course
# terraform plan
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
test
*.xml

# Terraform
*.tfstate
*.tfstate.*
.terraform/
terraform.tfvars

# Pulumi
pulumi/venv/
Pulumi.*.yaml

# IDE
.vscode/
.idea/

# OS
.DS_Store
shell.nix
4 changes: 4 additions & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vault_pass
*.retry
inventory/*.pyc
__pycache__/
Loading