Skip to content

Added home controller #5

Added home controller

Added home controller #5

Workflow file for this run

# 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 -q "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!"