-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (61 loc) · 2.33 KB
/
check.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
# Run this on all PRs
on:
pull_request:
permissions:
pull-requests: write
jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v2.1.1
check-lesson-102:
runs-on: ubuntu-latest
environment: Rails Academy API
steps:
- name: Can we contact the Rails Academy API?
run: |
curl -s -H "Authorization: Bearer ${{ secrets.RA_API_TOKEN }}" https://rails.academy/query || exit 1
- name: Checkout code
uses: actions/checkout@v3
- name: Check Rails files
run: |
# Check if Rails project files are present
if [ ! -f "Gemfile" ] || [ ! -f "config/routes.rb" ]; then
echo "Error: Rails project files are missing." >&2
exit 1
fi
- name: Check routes configuration
run: |
# Verify the root route is set to home#index
if ! grep -E "root ['\"]home#index['\"]" config/routes.rb; then
echo "Error: Root route is not set to home#index." >&2
exit 1
fi
- name: Check view content
run: |
# Check if "Hello World" is in the view
if ! grep -E "root ['\"]home#index['\"]" config/routes.rb; then
echo "Error: 'Hello World' is not found in app/views/home/index.html.erb." >&2
exit 1
fi
- name: Register with Rails Academy
run: |
GITHUB_USERNAME=${{ github.actor }}
GITHUB_ID=${{ github.actor_id }}
echo "Registering for Lesson 102 for GitHub user '$GITHUB_USERNAME'..."
RESPONSE=$(curl -s -X POST \
-H "Authorization: Bearer ${{ secrets.RA_API_TOKEN }}" \
-d "github_id=$GITHUB_ID" \
-d "github_username=$GITHUB_USERNAME" \
-d "lesson=102" \
-w "%{http_code}" \
-o /tmp/lesson_response_body.txt \
https://rails.academy/commands/finish_lesson)
if [ "$RESPONSE" -ne 200 ]; then
echo "Error: Failed to register Lesson 102. HTTP Status: $RESPONSE" >&2
echo "Response Body: $(cat /tmp/lesson_response_body.txt)" >&2
exit 1
fi
echo "Successfully registered Lesson 102 for GitHub user '$GITHUB_USERNAME'."
- name: Success
run: echo "All checks passed for Lesson 102!"