From 7813095958f80b7d10a2d964002a114ed6647773 Mon Sep 17 00:00:00 2001 From: Illia Shestakov Date: Wed, 23 Aug 2023 12:52:26 +0300 Subject: [PATCH] Synchronize with GitLab on every commit to main --- .github/workflows/sync.yml | 21 ++++++ .github/workflows/tutor.yml | 130 ------------------------------------ 2 files changed, 21 insertions(+), 130 deletions(-) create mode 100644 .github/workflows/sync.yml delete mode 100644 .github/workflows/tutor.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 00000000..43be4dbe --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,21 @@ +name: Sync with private repo + +on: + push: + branches: [ main ] + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Sync to GitLab + run: | + mkdir -p ~/.ssh && chmod 700 ~/.ssh + eval $(ssh-agent -s) + echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts + echo "${{ secrets.SSH_PRIVATE_KEY }}" | ssh-add - + git remote add gitlab git@gitlab.com:abstract-germany/community-theme/community-theme-tutor.git + git push gitlab $GITHUB_REF diff --git a/.github/workflows/tutor.yml b/.github/workflows/tutor.yml deleted file mode 100644 index 09842133..00000000 --- a/.github/workflows/tutor.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: CI - -on: - push: - branches: [ "main" ] - workflow_dispatch: - inputs: - skip_build_openedx_job: - required: true - type: boolean - default: true - skip_build_mfe_job: - required: true - type: boolean - default: true -env: - DOCKER_BUILDX: "1" - SERVER_IP: babilonia.abzt.de - TUTOR_ROOT: ${{ github.repository }} - TUTOR_PLUGINS_ROOT: $TUTOR_ROOT/plugins - OPENEDX_CACHE_IMAGE: docker.io/abstract2tech/community-theme-openedx-cache - MFE_CACHE_IMAGE: docker.io/abstract2tech/community-theme-mfe-cache - -jobs: - build-openedx: - env: - OPENEDX_IMAGE: docker.io/abstract2tech/community-theme-openedx:16.1.0 - runs-on: ubuntu-latest - if : ${{ !inputs.skip_build_openedx_job }} - steps: - - uses: actions/checkout@v3 - - - name: Export TUTOR_ variables - run: | - echo "TUTOR_ROOT=${GITHUB_WORKSPACE}" >> ${GITHUB_ENV} - echo "TUTOR_PLUGINS_ROOT=${GITHUB_WORKSPACE}/plugins" >> ${GITHUB_ENV} - echo "TUTOR_APP=community-theme" >> ${GITHUB_ENV} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker buildx - run: docker buildx create --use - - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - - name: Install requirements - run: pip install -r requirements.txt - - - name: Generate tutor env - run: tutor config save - - - name: Build tutor openedx image - run: | - docker login -u abstract2tech -p ${{ secrets.DOCKER_REGISTRY_PASSWORD }} - tutor images build openedx - tutor images push openedx - - build-mfe: - runs-on: ubuntu-latest - env: - MFE_IMAGE: docker.io/abstract2tech/community-theme-mfe:16.1.0 - steps: - - uses: actions/checkout@v3 - - - name: Export TUTOR_ variables - run: | - echo "TUTOR_ROOT=${GITHUB_WORKSPACE}" >> ${GITHUB_ENV} - echo "TUTOR_PLUGINS_ROOT=${GITHUB_WORKSPACE}/plugins" >> ${GITHUB_ENV} - echo "TUTOR_APP=community-theme" >> ${GITHUB_ENV} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - - name: Install requirements - run: pip install -r requirements.txt - - - name: Docker buildx - run: docker buildx create --use - - - name: Generate tutor env - run: tutor config save - - - name: Build tutor MFE image - run: | - docker login -u abstract2tech -p ${{ secrets.DOCKER_REGISTRY_PASSWORD }} - tutor images build mfe - tutor images push mfe - - deploy: - runs-on: ubuntu-latest - environment: production - if: ${{ always() && (needs.build-openedx.result == 'success' || needs.build-openedx.result == 'skipped') }} - needs: [build-openedx, build-mfe] - steps: - - uses: actions/checkout@v3 - - - name: Add SSH key to agent - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }} - run: | - eval $(ssh-agent) - if [ ! -d ~/.ssh ]; then - mkdir -p ~/.ssh && chmod 700 ~/.ssh - fi - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-add ~/.ssh/id_rsa - ssh-keyscan babilonia.abzt.de > ~/.ssh/known_hosts - pip install ansible==7.2.0 - ansible-galaxy install -r requirements.yml -p ansible/roles/ - cd $GITHUB_WORKSPACE/ansible - echo "$ANSIBLE_VAULT_PASSWORD" > vault_pass - chmod 600 vault_pass - ansible-playbook --vault-password-file ./vault_pass -u tutor -i inventory.ini -l babilonia.abzt.de --tags tutor_deploy tutor.yml