Skip to content

CI Pipeline

CI Pipeline #16

Workflow file for this run

name: CI Pipeline
on:
workflow_dispatch:
inputs:
pull_request_id:
description: 'Pull Request ID'
required: true
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 Branch Name from Pull Request ID
id: get_branch
run: |
PR_ID=${{ github.event.inputs.pull_request_id }}
PR_DATA=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_ID)
BRANCH_NAME=$(echo $PR_DATA | jq -r .head.ref)
echo "Branch Name: $BRANCH_NAME"
echo "::set-output name=branch_name::$BRANCH_NAME"
working-directory: ./code-dot-org
- name: Checkout Branch
uses: actions/checkout@v2
with:
ref: ${{ steps.get_branch.outputs.branch_name }}
path: code-dot-org
- name: Set up Docker Environment
run: docker build -t my-ci-image -f ./docker/dockerfiles/Dockerfile .
working-directory: ./code-dot-org
- name: Run Unit Tests
run: |
docker run my-ci-image /bin/bash -c "source ./docker/unit_test.sh"
working-directory: ./code-dot-org
- name: Run UI Tests
run: |
docker run my-ci-image /bin/bash -c "source ./docker/ui_tests.sh"
working-directory: ./code-dot-org
- name: Update Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}