CI Pipeline #66
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 | |
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: Find and Cache Stale Files | |
id: stalefiles | |
run: | | |
find code-dot-org -type f -not -path './.git/*' -mtime +730 > stale_files.txt | |
echo "::set-output name=stale_hash::$(sha256sum stale_files.txt | cut -d ' ' -f1)" | |
- name: Cache stale files | |
uses: actions/cache@v2 | |
with: | |
path: | | |
$(cat stale_files.txt) | |
key: ${{ runner.os }}-stale-${{ steps.stalefiles.outputs.stale_hash }} | |
- 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: Debugging Directories and Files in Docker | |
run: | | |
echo "Debugging / Directory" | |
docker run code-dot-org-testing-docker-image /bin/bash -c "ls -la /" | |
echo "Debugging /home Directory" | |
docker run code-dot-org-testing-docker-image /bin/bash -c "ls -la /home" | |
echo "Debugging /circleci Directory" | |
docker run --entrypoint /bin/bash code-dot-org-testing-docker-image -c "ls -la /circleci || mkdir -p /circleci && ls -la /circleci" | |
echo "Debugging deeper into /circleci" | |
docker run code-dot-org-testing-docker-image /bin/bash -c "ls -laR /circleci" | |
echo "Searching for ui_tests.sh in /circleci" | |
docker run code-dot-org-testing-docker-image /bin/bash -c "find /circleci -type f -name 'ui_tests.sh' 2>/dev/null" | |
echo "Displaying Environment Variables" | |
docker run 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') }} |