diff --git a/.github/workflows/deploy-develop-branch.yaml b/.github/workflows/deploy-develop-branch.yaml new file mode 100644 index 00000000..8084f0f0 --- /dev/null +++ b/.github/workflows/deploy-develop-branch.yaml @@ -0,0 +1,44 @@ +name: Deploy to develop + +on: + pull_request: + types: [unlabeled] + +jobs: + get-removed-labels: + runs-on: ubuntu-latest + steps: + - name: Get the removed label + run: | + # The path to the JSON file with the event payload + EVENT_PAYLOAD_PATH=${{ github.event_path }} + + # Extract the label name using jq (a lightweight and flexible command-line JSON processor) + LABEL_NAME=$(jq '.label.name' $EVENT_PAYLOAD_PATH) + + # Output the label name + echo $LABEL_NAME + + # Deploy to develop to test server + deploy: + needs: [ get-removed-labels ] + uses: ./.github/workflows/deploy.yaml + if: ${{ needs.get-removed-labels.outputs.result }} == 'deploy:aeolus-test' || ${{ needs.get-removed-labels.outputs.result }} == 'lock:aeolus-test' + with: + docker-tag: "nightly" + branch-name: "develop" + environment-name: aeolus-dev + environment-url: https://aeolus-test.artemis.cit.tum.de + secrets: inherit + + + # Check that the build job has run successfully otherwise add an error label + add-error-label: + needs: [ deploy ] + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - name: Add error label + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: deployment-error \ No newline at end of file diff --git a/deployment/aeolus-docker b/deployment/aeolus-docker index 1aebc8b3..541934a0 100644 --- a/deployment/aeolus-docker +++ b/deployment/aeolus-docker @@ -31,6 +31,13 @@ function start { cd $WORKING_DIR || exit git clone https://github.com/ls1intum/Aeolus.git -b "$pr_branch" Aeolus sed -i "s/AEOLUS_DOCKER_TAG=.*/AEOLUS_DOCKER_TAG='$pr_tag'/g" $ENV_FILE + if [ ! -f "$WORKING_DIR/docker.env" ]; then + wget -O "$WORKING_DIR/docker.env" https://raw.githubusercontent.com/ls1intum/Aeolus/develop/.env.example + sed -i "s/AEOLUS_DOCKER_TAG=.*/AEOLUS_DOCKER_TAG='$pr_tag'/g" $WORKING_DIR/docker.env + local _hostname + _hostname=$(hostname) + sed -i "s/AEOLUS_HOST=.*/AEOLUS_HOST='${_hostname}'/g" $WORKING_DIR/docker.env + fi if [ ! -f "$WORKING_DIR/acme.json" ]; then touch "$WORKING_DIR/acme.json" chmod 600 "$WORKING_DIR/acme.json" @@ -42,14 +49,13 @@ function start { } function stop { - # TODO: In the future extract pr_tag and pr_branch from env - echo "Stopping aeolus" docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" down } function restart { stop "$@" + sleep 1 start "$@" }