Merge pull request #56008 from code-dot-org/pablo-code-org-patch-1 #4
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: | ||
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 | ||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
if: github.actor == 'pablo-code-org' | ||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | ||
ports: | ||
- 3306:3306 | ||
steps: | ||
- name: Get EC2 Hostname | ||
uses: curlimages/curl@latest | ||
with: | ||
entrypoint: /bin/sh | ||
args: -c | | ||
IMDS_TOKEN=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") | ||
hostname=$(curl -s -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" http://169.254.169.254/latest/meta-data/public-hostname) | ||
echo "Running on $hostname" | ||
- name: Clone and Prepare Git | ||
run: | | ||
git clone --branch $DRONE_SOURCE_BRANCH --depth 1 $DRONE_GIT_HTTP_URL . | ||
git reset --hard $DRONE_COMMIT | ||
git remote set-branches --add origin $DRONE_TARGET_BRANCH | ||
git fetch --depth 100 origin $DRONE_TARGET_BRANCH | ||
git config user.name "Drone" | ||
git config user.email "drone-fake-user@code.org" | ||
git merge origin/$DRONE_TARGET_BRANCH | ||
- name: Restore Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | ||
- name: Set up Docker Environment | ||
run: | | ||
docker build -t my-ci-image . | ||
- name: Run Unit Tests | ||
run: | | ||
docker run my-ci-image /bin/bash -c "source docker/unit_test.sh" | ||
- name: Run UI Tests | ||
run: | | ||
docker run my-ci-image /bin/bash -c "source docker/ui_tests.sh" | ||
- name: Update Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |