Skip to content

Dev container & GitLab mirroring #25

Dev container & GitLab mirroring

Dev container & GitLab mirroring #25

Workflow file for this run

name: CI/CD Workflow
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
cd frontend
npm i
- name: Run Prettier
run: |
cd frontend
npm run lint
ruff:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Poetry
run: |
pip install poetry
cd backend
poetry install
- name: Run Ruff
run: |
cd backend
poetry run ruff check .
sonarcloud:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarCloud scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
docker-backend:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- ruff
- sonarcloud
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:backend"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/synthra-backend:latest
docker-frontend:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- eslint
- sonarcloud
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:frontend"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/synthra-frontend:latest
gitlab-mirror:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- docker-frontend
- docker-backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Push to GitLab
env:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_REPO: ${{ secrets.GITLAB_REPO }}
GITLAB_ORG: ${{ secrets.GITLAB_ORG }}
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git remote add gitlab "${GITLAB_URL}/${GITLAB_ORG}/${GITLAB_REPO}.git"
git push gitlab HEAD:master --force