revert change #697
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: Build, test & deploy | |
on: [ push, pull_request ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Docker login | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin | |
- name: Disable make sync | |
run: touch submodule_sync | |
- name: Install pre-commit | |
run: pip install pre-commit==3.8.0 | |
- name: Run pre-commit | |
run: pre-commit run -a | |
- name: Build image | |
run: make | |
- name: Run test | |
run: make test | |
- name: Build frontend | |
run: make build_frontend | |
- name: Copy frontend static files to backend | |
run: cp -r frontend/build/* backend/frontend_static/ | |
- name: Build image to copy FE into it | |
run: make | |
- name: Tag sha | |
run: docker tag bis-backend ${{ env.IMAGE_NAME }}:$GITHUB_SHA | |
- name: Push sha | |
run: docker push ${{ env.IMAGE_NAME }}:$GITHUB_SHA | |
deploy-dev: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Deploy new tag | |
run: curl -X POST --fail -F token=${{ secrets.GITLAB_TOKEN }} -F "ref=main" -F "variables[TARGET_ENV]=devel" -F "variables[TARGET_TAG]=$GITHUB_SHA" https://gitlab.com/api/v4/projects/43999052/trigger/pipeline | |
deploy-prod: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Docker login | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin | |
- name: Pull sha | |
run: docker pull ${{ env.IMAGE_NAME }}:$GITHUB_SHA | |
- name: Tag sha | |
run: docker tag ${{ env.IMAGE_NAME }}:$GITHUB_SHA ${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/*/} | |
- name: Push tag | |
run: docker push ${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/*/} | |
- name: Deploy new tag | |
run: curl -X POST --fail -F token=${{ secrets.GITLAB_TOKEN }} -F "ref=main" -F "variables[TARGET_ENV]=production" -F "variables[TARGET_TAG]=${GITHUB_REF#refs/*/}" https://gitlab.com/api/v4/projects/43999052/trigger/pipeline |