Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD feature: deploy documetation with GitHub Actions #23

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
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
51 changes: 44 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:

env:
go-version: '1.21.5'
python-version: '3.12'
cmd-name: 'greenmask'
docker-registry: greenmask/greenmask

Expand All @@ -30,10 +31,10 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}

- name: Echo Go version
run: go version

- name: Run tests
run: make tests

Expand All @@ -47,17 +48,17 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run integration tests
run: |
docker-compose -f docker-compose-integration.yml -p greenmask up \
--renew-anon-volumes --force-recreate --build --exit-code-from greenmask \
--abort-on-container-exit greenmask

binaries:
build-binaries:
runs-on: ubuntu-22.04
needs:
- unit-tests
Expand All @@ -84,7 +85,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}

- name: Build with different arch
run: |
export GOOS=$(echo ${{ matrix.platforms }} | cut -d '/' -f 1)
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:
build-docker-images-and-push:
runs-on: ubuntu-22.04
needs:
- binaries
- build-binaries
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
Expand Down Expand Up @@ -160,3 +161,39 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.docker-registry }}:${{ env.TAG }},${{ env.docker-registry }}:latest

deploy-docs:
runs-on: self-hosted
needs:
- build-binaries
- build-docker-images-and-push
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}

- name: Install dependicies
run: pip install -r requirements.txt

- name: Build docs
run: mkdocs build

- name: Create directory
run: sudo mkdir -p /var/www/greenmask.io

- name: Move docs to greenmask.io directory
run: sudo mv site /var/www/greenmask.io/html-${{ github.ref_name}}

- name: Remove old symlink
run: sudo unlink /var/www/greenmask.io/html

- name: Create new symlink
run: sudo ln -s /var/www/greenmask.io/html-${{ github.ref_name}} /var/www/greenmask.io/html

- name: Restart web service
run: sudo systemctl restart nginx