-
Notifications
You must be signed in to change notification settings - Fork 481
78 lines (65 loc) · 2.54 KB
/
ci_pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: CI Pipeline
on:
workflow_dispatch:
# Add additional trigger events as needed (e.g., push, pull_request, etc.)
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'
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: Get Branch Name from Hardcoded Pull Request ID
id: get_branch
run: |
PR_ID=55766
PR_DATA=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/code-dot-org/code-dot-org/pulls/$PR_ID)
BRANCH_NAME=$(echo $PR_DATA | jq -r .head.ref)
echo "Branch Name: $BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Checkout Branch
uses: actions/checkout@v2
with:
ref: ${{ steps.get_branch.outputs.branch_name }}
path: code-dot-org
repository: code-dot-org/code-dot-org
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- 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: Find ui_tests.sh file
run: |
docker run --rm --entrypoint /bin/bash \
code-dot-org-testing-docker-image \
-c "find / -type f -name 'ui_tests.sh' 2>/dev/null"
- name: Run ls Unit Tests without working dir
run: |
docker run \
code-dot-org-testing-docker-image \
/bin/bash -c "ls -la ."
- name: Update Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}