[pre-commit.ci] pre-commit autoupdate #159
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
with: | |
fetch-depth: 0 | |
- name: Push to GitLab | |
env: | |
GITLAB_URL: ${{ secrets.GITLAB_URL }} | |
GITLAB_MAIL: ${{ secrets.GITLAB_MAIL }} | |
GITLAB_REPO: ${{ secrets.GITLAB_REPO }} | |
GITLAB_ORG: ${{ secrets.GITLAB_ORG }} | |
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }} | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
run: | | |
git config --global user.email "${GITLAB_MAIL}" | |
git config --global user.name "${GITLAB_USERNAME}" | |
git remote add gitlab "https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@gitlab.finki.ukim.mk/ioss/synthra.git" | |
git push gitlab main:main --force |