CI Pipeline #72
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: CI Pipeline | |
on: | |
workflow_dispatch: | |
inputs: | |
pr_id: | |
description: 'Pull Request ID' | |
required: false | |
default: '55766' | |
env: | |
AWS_DEFAULT_REGION: us-east-1 | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
MYSQL_ROOT_PASSWORD: root | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-reviewers: | |
runs-on: ubuntu-latest | |
outputs: | |
has_infrastructure_reviewer: ${{ steps.check.outputs.has_infrastructure_reviewer }} | |
steps: | |
- name: Check for Infrastructure Reviewers | |
id: check | |
run: | | |
PR_ID=${{ github.event.inputs.pr_id }} | |
REVIEWERS=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/code-dot-org/code-dot-org/pulls/$PR_ID/reviewers) | |
if [[ $REVIEWERS == *"infrastructure"* ]]; then | |
echo "has_infrastructure_reviewer=true" >> $GITHUB_ENV | |
else | |
echo "has_infrastructure_reviewer=false" >> $GITHUB_ENV | |
fi | |
build-and-test: | |
needs: check-reviewers | |
runs-on: ubuntu-latest | |
if: needs.check-reviewers.outputs.has_infrastructure_reviewer == 'true' || github.actor == 'pablo-code-org' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
path: code-dot-org | |
- name: Prepare entrypoint script | |
run: cp ./code-dot-org/docker/dockerfiles/entrypoint.sh ./code-dot-org/ | |
- name: Set up Docker Environment | |
run: docker build -t code-dot-org-testing-docker-image -f ./code-dot-org/docker/dockerfiles/Dockerfile ./code-dot-org | |
- name: Setup upterm session | |
uses: lhotari/action-upterm@v1 | |
- name: Debugging Directories and Files in Docker as User CircleCI | |
run: | | |
echo "Searching for ui_tests.sh in /circleci as circleci" | |
docker run --user circleci code-dot-org-testing-docker-image /bin/bash -c "find /circleci -type f -name 'ui_tests.sh'" | |
echo "Displaying Environment Variables as circleci" | |
docker run --user circleci code-dot-org-testing-docker-image /bin/bash -c "printenv" | |
- name: Update Cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |