diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index df3c1d0..b949adb 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -27,3 +27,29 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-node - run: yarn lint:tsc + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-node + - run: yarn build + + # TODO: this is just a basic check to see if it is set up and running + # change for real tests later + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-node + - run: cp .env-template .env + - run: docker compose up mysql mongo -d + - run: sleep 30 + - run: + yarn mysql -e "CREATE TABLE lti_entity ( id bigint, resource_link_id + varchar(255), custom_claim_id varchar(255), content longtext, + id_token_on_creation text )" + - run: yarn build + - run: docker compose up express -d + - run: sleep 2 + - run: curl localhost:3000 | grep NO_LTIK_OR_IDTOKEN_FOUND diff --git a/.github/workflows/deploy-to-uberspace-dev.yml b/.github/workflows/deploy-to-uberspace-dev.yml deleted file mode 100644 index a105c0d..0000000 --- a/.github/workflows/deploy-to-uberspace-dev.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy to Uberspace development - -on: - push: - branches: [development] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Deploy to Server - uses: easingthemes/ssh-deploy@v5.1.1 - with: - ARGS: '-rlgoDzvc -i --delete' - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - REMOTE_HOST: ${{ secrets.REMOTE_HOST_DEV }} - REMOTE_USER: ${{ secrets.REMOTE_USER_DEV }} - SOURCE: '.' - TARGET: - '/home/${{ secrets.REMOTE_USER_DEV }}/serlo-editor-as-lti-tool/' - EXCLUDE: '/node_modules/' - SCRIPT_AFTER: | - cd /home/${{ secrets.REMOTE_USER_DEV }}/serlo-editor-as-lti-tool/ - yarn - yarn build - supervisorctl restart serlo-app diff --git a/.github/workflows/deploy-to-uberspace-staging.yml b/.github/workflows/deploy-to-uberspace-staging.yml deleted file mode 100644 index 3d7de61..0000000 --- a/.github/workflows/deploy-to-uberspace-staging.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy to Uberspace staging - -on: - push: - branches: [staging] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Deploy to Server - uses: easingthemes/ssh-deploy@v5.1.1 - with: - ARGS: '-rlgoDzvc -i --delete' - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - REMOTE_HOST: ${{ secrets.REMOTE_HOST_STAGING }} - REMOTE_USER: ${{ secrets.REMOTE_USER_STAGING }} - SOURCE: '.' - TARGET: - '/home/${{ secrets.REMOTE_USER_STAGING }}/serlo-editor-as-lti-tool/' - EXCLUDE: '/node_modules/' - SCRIPT_AFTER: | - cd /home/${{ secrets.REMOTE_USER_STAGING }}/serlo-editor-as-lti-tool/ - yarn - yarn build - supervisorctl restart serlo-app diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5b7ff89 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: Deploy to Uberspace + +on: + push: + branches: + - staging + - development + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set environment variables for development + if: ${{ github.ref_name == 'development' }} + run: | + echo "REMOTE_HOST=${{ secrets.REMOTE_HOST_DEV }}" >> $GITHUB_ENV + echo "REMOTE_USER=${{ secrets.REMOTE_USER_DEV }}" >> $GITHUB_ENV + echo "DOMAIN=https://editor.serlo.dev/" >> $GITHUB_ENV + + - name: Set environment variables for staging + if: ${{ github.ref_name == 'staging' }} + run: | + echo "REMOTE_HOST=${{ secrets.REMOTE_HOST_STAGING }}" >> $GITHUB_ENV + echo "REMOTE_USER=${{ secrets.REMOTE_USER_STAGING }}" >> $GITHUB_ENV + echo "DOMAIN=https://editor.serlo-staging.dev/" >> $GITHUB_ENV + + - name: Deploy to Server + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ env.REMOTE_HOST }} + username: ${{ env.REMOTE_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + cd /home/${{ env.REMOTE_USER }}/serlo-editor-as-lti-tool/ + git checkout ${{ github.ref_name }} + git pull + yarn + yarn build + supervisorctl restart serlo-app + + - name: Test deployment successful + run: curl ${{ env.DOMAIN }} | grep NO_LTIK_OR_IDTOKEN_FOUND diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml deleted file mode 100644 index 7e429f3..0000000 --- a/.github/workflows/push-docker-image.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Push Docker Image - -on: - push: - paths: - - 'package.json' - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Get version from package.json - id: package-version - run: | - VERSION=$(grep -m1 '"version":' package.json | awk -F: '{ print $2 }' | sed 's/[", ]//g') - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - - - name: Check if version exists - id: check-version - run: | - if docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.package-version.outputs.VERSION }} > /dev/null 2>&1; then - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi - - - name: Build and push Docker image - if: steps.check-version.outputs.exists == 'false' - uses: docker/build-push-action@v6 - with: - context: . - file: Dockerfile.dev - push: true - tags: - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ - steps.package-version.outputs.VERSION }} - labels: ${{ steps.meta.outputs.labels }}