diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 83018401..7ad3dd5a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,5 +8,14 @@ ### Steps for Testing +### Testserver States +> [!NOTE] +> These badges show the state of the test servers. +> Green = Currently available, Red = Currently locked +> Click on the badges to get to the test servers. + +[![](https://byob.yarr.is/ls1intum/Athena/athena-test1)](https://athena-test1.ase.cit.tum.de) +[![](https://byob.yarr.is/ls1intum/Athena/athena-test2)](https://athena-test2.ase.cit.tum.de) + ### Screenshots - \ No newline at end of file + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6bbcd68..c67089bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: Build Docker Images -# Build the Docker images for the the assessment module manager, the modules and the playground. +# Build the Docker images for the assessment module manager, the modules and the playground. # Because the Python images depend on the athena Python package, the package is built first. on: @@ -91,4 +91,4 @@ jobs: ATHENA_COMMIT_SHA=${{ github.event.pull_request.head.sha || github.sha }} ATHENA_PR_NUMBER=${{ github.event.pull_request.number }} ATHENA_PR_TITLE=${{ github.event.pull_request.title }} - ATHENA_PR_LAST_UPDATE=${{ github.event.pull_request.updated_at }} \ No newline at end of file + ATHENA_PR_LAST_UPDATE=${{ github.event.pull_request.updated_at }} diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml deleted file mode 100644 index 9989c411..00000000 --- a/.github/workflows/deploy-test.yml +++ /dev/null @@ -1,174 +0,0 @@ -name: Deploy to Athena Test - -on: - pull_request: - types: [labeled] - -permissions: write-all - -jobs: - # Get an up to date version of the label list. github.event.pull_request.labels seems to sometimes be outdated - # if the run was waiting for a while, which can cause duplicate deployments - get-labels: - runs-on: ubuntu-latest - outputs: - labels: ${{ steps.get-labels.outputs.result }} - steps: - - name: Get PR labels - id: get-labels - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const response = await github.rest.issues.listLabelsOnIssue({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number - }) - const labels = response.data - return labels.map(label => label.name) - - - # Check that the build job has run successfully before deploying - check-build-status: - needs: [ get-labels ] - runs-on: ubuntu-latest - # Only run workflow if the added label is a deploy label - if: contains(needs.get-labels.outputs.labels, 'deploy:athena-test1') - steps: - - name: Get latest successful build for branch - id: check_build - uses: octokit/request-action@v2.x - with: - route: GET /repos/${{ github.repository }}/actions/workflows/build.yml/runs?event=pull_request&status=success&head_sha=${{ github.event.pull_request.head.sha }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Remove deployment-error label if new run is started - - uses: actions-ecosystem/action-remove-labels@v1 - if: fromJSON(steps.check_build.outputs.data).total_count > 0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: | - deployment-error - - # In case of invalid build status, remove deploy labels - - uses: actions-ecosystem/action-remove-labels@v1 - if: fromJSON(steps.check_build.outputs.data).total_count == 0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: | - deploy:athena-test1 - - - name: Check if latest push had successful build - if: fromJSON(steps.check_build.outputs.data).total_count == 0 - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '### ❌ Unable to deploy to test server ❌\nThe docker build needs to run through before deploying.' - }) - core.setFailed('The build needs to run through first. Please wait for the build to finish and then try again.') - - # Compute the tag to use for the docker image - compute-tag: - needs: [ check-build-status ] - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.compute-tag.outputs.result }} - steps: - - name: Compute Tag - uses: actions/github-script@v6 - id: compute-tag - with: - result-encoding: string - script: | - if (context.eventName === "pull_request") { - return "pr-" + context.issue.number; - } - if (context.eventName === "release") { - return "latest"; - } - if (context.eventName === "push") { - if (context.ref.startsWith("refs/tags/")) { - return context.ref; - } - if (context.ref === "refs/heads/develop") { - return "develop"; - } - } - return "FALSE"; - - # Run pre-deployment steps - pre-deployment: - needs: [ compute-tag ] - runs-on: ubuntu-latest - steps: - - uses: actions-ecosystem/action-remove-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: | - deploy:athena-test1 - - - name: Check "lock:athena-test1" label - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const opts = github.rest.issues.listForRepo.endpoint.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['lock:athena-test1'] - }) - const issues = await github.paginate(opts) - if (issues.length == 1 && (!context.issue || issues[0].number != context.issue.number)) { - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `### ❌ Unable to deploy to test server ❌\nAthena Testserver is already in use by PR #${issues[0].number}.` - }) - core.setFailed(`Athena Testserver is already in use by PR #${issues[0].number}.`); - } else if (issues.length > 1) { - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '### ❌ Unable to deploy to test server ❌\nAthena Testserver is already in use by multiple PRs. Check PRs with label "lock:pyris-test"!' - }) - core.setFailed('Athena Testserver is already in use by multiple PRs. Check PRs with label "lock:athena-test1"!'); - } else if (context.issue && context.issue.number) { - await github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['lock:athena-test1'] - }) - } - - # Deploy to the test servers - deploy: - needs: [ compute-tag, pre-deployment ] - uses: ./.github/workflows/deploy.yml - with: - docker-tag: ${{ needs.compute-tag.outputs.tag }} - branch-name: ${{ github.event.pull_request.head.ref }} - environment-name: Athena Test Server 1 - environment-url: https://athena-test1.ase.cit.tum.de/ - secrets: inherit - - - # Check that the build job has run successfully otherwise add an error label - add-error-label: - needs: [ check-build-status, compute-tag, pre-deployment, deploy ] - runs-on: ubuntu-latest - if: ${{ failure() }} - steps: - - name: Add error label - uses: actions-ecosystem/action-add-labels@v1 - with: - labels: deployment-error diff --git a/.github/workflows/deploy-testserver.yml b/.github/workflows/deploy-testserver.yml new file mode 100644 index 00000000..4c0009d5 --- /dev/null +++ b/.github/workflows/deploy-testserver.yml @@ -0,0 +1,274 @@ +name: Deploy to Athena Test Server + +on: + pull_request: + types: [labeled] + +concurrency: test-servers + +env: + RAW_URL: https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }} + +jobs: + # Get an up to date version of the label list. github.event.pull_request.labels seems to sometimes be outdated + # if the run was waiting for a while, which can cause duplicate deployments + get-labels: + runs-on: ubuntu-latest + outputs: + labels: ${{ steps.get-labels.outputs.result }} + steps: + - name: Get PR labels + id: get-labels + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const response = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }) + const labels = response.data + return labels.map(label => label.name) + + + # Check that the build job has run successfully before deploying + check-build-status: + needs: [ get-labels ] + runs-on: ubuntu-latest + # Only run workflow if the added label is a deploy label + if: contains(needs.get-labels.outputs.labels, 'deploy:athena-test') + steps: + - name: Get latest successful build for branch + id: check_build + uses: octokit/request-action@v2.x + with: + route: GET /repos/${{ github.repository }}/actions/workflows/build.yml/runs?event=pull_request&status=success&head_sha=${{ github.event.pull_request.head.sha }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Remove deployment-error label if new run is started + - uses: actions-ecosystem/action-remove-labels@v1 + if: fromJSON(steps.check_build.outputs.data).total_count > 0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: | + deployment-error + + # In case of invalid build status, remove deploy labels + - uses: actions-ecosystem/action-remove-labels@v1 + if: fromJSON(steps.check_build.outputs.data).total_count == 0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: | + deploy:athena-test1 + deploy:athena-test2 + + - name: Check if latest push had successful build + if: fromJSON(steps.check_build.outputs.data).total_count == 0 + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '### ⚠️ Unable to deploy to test servers ⚠️\nThe docker build needs to run through before deploying.' + }) + core.setFailed('The build needs to run through first. Please wait for the build to finish and then try again.') + + # Check which test server to deploy to based on the label + filter-matrix: + needs: [ get-labels, check-build-status ] + runs-on: ubuntu-latest + strategy: + matrix: + include: + - environment: athena-test1.ase.cit.tum.de + label-identifier: athena-test1 + url: https://athena-test1.ase.cit.tum.de + user: ${{ vars.DEPLOYMENT_USER }} + hosts: athena-test1.ase.cit.tum.de + folder: ${{ vars.DEPLOYMENT_FOLDER }} + + - environment: athena-test2.ase.cit.tum.de + label-identifier: athena-test2 + url: https://athena-test2.ase.cit.tum.de + user: ${{ vars.DEPLOYMENT_USER }} + hosts: athena-test2.ase.cit.tum.de + folder: ${{ vars.DEPLOYMENT_FOLDER }} + outputs: + TS1: ${{ steps.filter.outputs.athena-test1 || '' }} + TS2: ${{ steps.filter.outputs.athena-test2 || '' }} + steps: + - run: | + echo "$DEPLOY_LABEL" + echo '${{ contains(fromJSON(needs.get-labels.outputs.labels), format('deploy:{0}', matrix.label-identifier)) }}' + - id: filter + env: + MATRIX_JSON: ${{ toJSON(matrix) }} + if: ${{ contains(fromJSON(needs.get-labels.outputs.labels), format('deploy:{0}', matrix.label-identifier)) }} + run: | + MATRIX_JSON=${MATRIX_JSON//$'\n'/} + echo "${{ matrix.label-identifier }}=$MATRIX_JSON" >> $GITHUB_OUTPUT + + + # Process the output of the filter step to create a valid matrix for the deploy step + process-matrix: + needs: [ filter-matrix ] + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.process.outputs.matrix }} + steps: + - id: process + env: + MATRIX_JSON: ${{ toJSON(needs.filter-matrix.outputs.*) }} + run: | + MATRIX_JSON=${MATRIX_JSON//$'\n'/} + MATRIX_JSON=${MATRIX_JSON//$'"{'/'{'} + MATRIX_JSON=${MATRIX_JSON//$'}"'/'}'} + MATRIX_JSON=${MATRIX_JSON//$'\\"'/'"'} + echo "$MATRIX_JSON" + echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT + + + # Deploy to the test servers + deploy: + needs: [ process-matrix ] + runs-on: ubuntu-latest + concurrency: test-servers-deploy + strategy: + fail-fast: false + matrix: + include: ${{ fromJSON(needs.process-matrix.outputs.matrix) }} + + environment: + name: ${{ matrix.environment }} + url: ${{ matrix.url }} + + env: + DEPLOYMENT_USER: ${{ matrix.user }} + DEPLOYMENT_HOST: ${{ matrix.hosts }} + DEPLOYMENT_FOLDER: ${{ matrix.folder }} + GATEWAY_USER: "jump" + GATEWAY_HOST: "gateway.artemis.in.tum.de:2010" + GATEWAY_HOST_PUBLIC_KEY: "[gateway.artemis.in.tum.de]:2010 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtTLiKRILjKZ+Qg4ReWKsG7mLDXkzHfeY5nalSQUNQ4" + + steps: + - uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: | + deploy:${{ matrix.label-identifier }} + + - name: Check "lock:${{ matrix.label-identifier }}" label + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const opts = github.rest.issues.listForRepo.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['lock:${{ matrix.label-identifier }}'] + }) + const issues = await github.paginate(opts) + if (issues.length == 1 && (!context.issue || issues[0].number != context.issue.number)) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `#### ⚠️ Unable to deploy to test server ⚠️\nAthena Testserver "${{ matrix.environment }}" is already in use by PR #${issues[0].number}.` + }) + core.setFailed(`Athena Testserver "${{ matrix.environment }}" is already in use by PR #${issues[0].number}.`); + } else if (issues.length > 1) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '#### ⚠️ Unable to deploy to test server ⚠️\nAthena Testserver "${{ matrix.environment }}" is already in use by multiple PRs. Check PRs with label "lock:${{ matrix.label-identifier }}"!' + }) + core.setFailed('Athena Testserver "${{ matrix.environment }}" is already in use by multiple PRs. Check PRs with label "lock:${{ matrix.label-identifier }}"!'); + } + + - name: Compute Tag + uses: actions/github-script@v7 + id: compute-tag + with: + result-encoding: string + script: | + if (context.eventName === "pull_request") { + return "pr-" + context.issue.number; + } + if (context.eventName === "release") { + return "latest"; + } + if (context.eventName === "push") { + if (context.ref.startsWith("refs/tags/")) { + return context.ref.slice(10); + } + if (context.ref === "refs/heads/develop") { + return "develop"; + } + } + return "FALSE"; + + # Download athena-server-cli from GH without cloning the Repo + - name: Fetch Athena CLI + run: | + wget ${{ env.RAW_URL }}/athena-server-cli + chmod +x athena-server-cli + + # Configure SSH Key + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + GATEWAY_SSH_KEY: "${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}" + DEPLOYMENT_SSH_KEY: "${{ secrets.DEPLOYMENT_SSH_KEY }}" + run: | + mkdir -p ~/.ssh + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< $GATEWAY_SSH_KEY + ssh-add - <<< $DEPLOYMENT_SSH_KEY + cat - <<< $GATEWAY_HOST_PUBLIC_KEY >> ~/.ssh/known_hosts + + - name: Deploy Athena with Docker + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + TAG: ${{ steps.compute-tag.outputs.result }} + run: | + ./athena-server-cli docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $TAG -b $GITHUB_HEAD_REF -d $DEPLOYMENT_FOLDER -y + + - name: Add "lock:${{ matrix.label-identifier }}" label + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + if (context.issue && context.issue.number) { + await github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['lock:${{ matrix.label-identifier }}'] + }) + } + + - name: Update badge + uses: RubbaBoy/BYOB@v1.3.0 + with: + NAME: ${{ matrix.label-identifier }} + LABEL: ${{ matrix.environment }} + STATUS: ${{ github.event.pull_request.head.ref }} + COLOR: red + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Check that the build job has run successfully before deploying, otherwise add an error label + add-error-label: + needs: [ get-labels, check-build-status, filter-matrix, process-matrix, deploy ] + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - name: Add error label + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: deployment-error diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 0a1416e3..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Deploy - -on: - workflow_call: - inputs: - docker-tag: - required: true - type: string - branch-name: - required: true - type: string - environment-name: - required: true - type: string - environment-url: - required: true - type: string - secrets: - DEPLOYMENT_GATEWAY_SSH_KEY: - required: true - -concurrency: deploy - -env: - RAW_URL: https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }} - - -jobs: - deploy: - runs-on: ubuntu-latest - - environment: - name: ${{ inputs.environment-name }} - url: ${{ inputs.environment-url }} - - env: - DOCKER_TAG: ${{ inputs.docker-tag }} - BRANCH_NAME: ${{ inputs.branch-name }} - DEPLOYMENT_USER: ${{ vars.DEPLOYMENT_USER }} - DEPLOYMENT_HOST: ${{ vars.DEPLOYMENT_HOST }} - DEPLOYMENT_FOLDER: ${{ vars.DEPLOYMENT_FOLDER }} - DEPLOYMENT_HOST_PUBLIC_KEYS: ${{ vars.DEPLOYMENT_HOST_PUBLIC_KEYS }} - GATEWAY_USER: "jump" - GATEWAY_HOST: "gateway.artemis.in.tum.de:2010" - GATEWAY_HOST_PUBLIC_KEY: "[gateway.artemis.in.tum.de]:2010 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtTLiKRILjKZ+Qg4ReWKsG7mLDXkzHfeY5nalSQUNQ4" - - steps: - # Download athena-server-cli from GH without cloning the Repo - - name: Fetch Athena CLI - run: | - wget ${{ env.RAW_URL }}/athena-server-cli - chmod +x athena-server-cli - - # Configure SSH Key - - name: Setup SSH Keys and known_hosts - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - GATEWAY_SSH_KEY: "${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}" - DEPLOYMENT_SSH_KEY: "${{ secrets.DEPLOYMENT_SSH_KEY }}" - run: | - mkdir -p ~/.ssh - ssh-agent -a $SSH_AUTH_SOCK > /dev/null - ssh-add - <<< $GATEWAY_SSH_KEY - ssh-add - <<< $DEPLOYMENT_SSH_KEY - cat - <<< $GATEWAY_HOST_PUBLIC_KEY >> ~/.ssh/known_hosts - cat - <<< $(sed 's/\\n/\n/g' <<< "$DEPLOYMENT_HOST_PUBLIC_KEYS") >> ~/.ssh/known_hosts - - - name: Deploy Athena with Docker - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - run: | - ./athena-server-cli docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $DOCKER_TAG -b $BRANCH_NAME -d $DEPLOYMENT_FOLDER -y diff --git a/.github/workflows/pullrequest-closed.yml b/.github/workflows/pullrequest-closed.yml new file mode 100644 index 00000000..f77a0e7d --- /dev/null +++ b/.github/workflows/pullrequest-closed.yml @@ -0,0 +1,82 @@ +name: Pull Request Closed + +on: + pull_request_target: + types: [closed] + +jobs: + # If a PR is closed, the testserver lock should be removed and corresponding badges updated + process_labels: + name: Process labels + runs-on: ubuntu-latest + outputs: + labels: ${{ steps.process.outputs.labels }} + badges: ${{ steps.process.outputs.badges }} + steps: + - name: Process labels + id: process + uses: actions/github-script@v7 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + script: | + const labelsToRemove = []; + const labelsToProcess = []; + + // Get the PR number + const prNumber = context.payload.pull_request.number; + + // Iterate through labels on the PR + for (const label of context.payload.pull_request.labels) { + const labelName = label.name; + const regex = /^lock:athena-test(\d+)$/; + + if (regex.test(labelName)) { + // Extract the part after "lock:" using capture groups + const extractedLabel = labelName.match(regex)[1]; + labelsToProcess.push(extractedLabel); + labelsToRemove.push(labelName); + } + } + + // Do something with the extracted labels + console.log('Badges to process:', labelsToProcess); + console.log('Labels to remove:', labelsToRemove); + + // Use the labelsToRemove array to remove the matching labels + core.setOutput('badges', JSON.stringify(labelsToProcess)); + core.setOutput('labels', labelsToRemove.join(', ')); + + + remove_labels: + name: Remove labels + needs: process_labels + runs-on: ubuntu-latest + if: ${{ needs.process_labels.outputs.labels != '' }} + + steps: + - name: Remove labels + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: ${{ needs.process_labels.outputs.labels }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + update_badges: + name: Update badges + needs: process_labels + runs-on: ubuntu-latest + strategy: + matrix: + badge: ${{ fromJson(needs.process_labels.outputs.badges) }} + if: ${{ needs.process_labels.outputs.labels != '' }} + + steps: + - name: Update badge + uses: RubbaBoy/BYOB@v1.3.0 + with: + NAME: "athena-test${{ matrix.badge }}" + LABEL: "athena-test${{ matrix.badge }}.ase.cit.tum.de" + STATUS: ${{ github.event.pull_request.head.ref }} + COLOR: green + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pullrequest-unlabeled.yml b/.github/workflows/pullrequest-unlabeled.yml new file mode 100644 index 00000000..93fbc845 --- /dev/null +++ b/.github/workflows/pullrequest-unlabeled.yml @@ -0,0 +1,33 @@ +name: Pull Request Label Removal + +on: + pull_request_target: + types: + - unlabeled + +jobs: + update_badges: + name: Update test server badges + runs-on: ubuntu-latest + if: startsWith(github.event.label.name, 'lock:athena-test') + + steps: + - name: Get badge id + id: env + uses: actions/github-script@v7 + with: + script: | + const labelName = context.payload.label.name; + const badge = labelName.replace(/^lock:athena-test/, ''); + core.setOutput('BADGE', badge); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update badge + uses: RubbaBoy/BYOB@v1.3.0 + with: + NAME: "athena-test${{ steps.env.outputs.BADGE }}" + LABEL: "athena-test${{ steps.env.outputs.BADGE }}.ase.cit.tum.de" + STATUS: ${{ github.event.pull_request.head.ref }} + COLOR: green + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/testserver-locks.yml b/.github/workflows/testserver-locks.yml new file mode 100644 index 00000000..e950ee9c --- /dev/null +++ b/.github/workflows/testserver-locks.yml @@ -0,0 +1,20 @@ +name: Testserver Locks + +on: + pull_request_target: + types: [labeled] + issues: + types: [labeled] + +jobs: + # Disallow adding testserver locks to PRs manually + noManualSetOfLockLabel: + runs-on: ubuntu-latest + steps: + - uses: actions-ecosystem/action-remove-labels@v1 + if: startsWith(github.event.label.name, 'lock:athena-test') || startsWith(join(github.event.pull_request.labels.*.name), 'lock:athena-test') + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: | + lock:athena-test1 + lock:athena-test2