Skip to content

Update index.md

Update index.md #59

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
- "*"
pull_request:
types: [opened, ready_for_review, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
auto_assign:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Print repo structure
run: |
pwd
ls -al
ls -al .github || echo ".github directory does not exist"
cat .github/auto_assign.yml || echo "No .github/auto_assign.yml found"
- name: Print working directory and files
run: |
pwd
ls -al .github
cat .github/auto_assign.yml || echo "No auto_assign.yml found"
- uses: kentaro-m/auto-assign-action@v1.2.4
# Build stage - converting md file to html using MkDocs
convert_md_to_html:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main' # Run for non-main branches
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install MkDocs and dependencies
run: |
pip install mkdocs mkdocs-material
- name: Build project with MkDocs
run: |
echo "Building your project..."
mkdocs build
echo "pwd in build project with MKDocs"
pwd
- name: Debug MkDocs Build Output
run: |
echo "Contents of site directory:"
ls -l site
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: site
path: site
# Deployment to test folder in S3 bucket
deploy_to_test:
needs: convert_md_to_html
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main' # Run for non-main branches
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get PR number from GitHub API
id: pr
run: |
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
$PR_API_URL | jq '.[0].number')
echo "pr_number=$PR_NUMBER"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: site
path: site
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 # change if needed
- name: Deploy to Test Environment
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
$PR_API_URL | jq '.[0].number')
echo "pr_number while deploying =$PR_NUMBER"
pwd
#aws s3 ls
#aws s3 sync site/ s3://$S3_BUCKET_NAME/test
#aws s3 sync site/ s3://$S3_BUCKET_NAME/MergeRequest/$PR_NUMBER
# Deployment to production folder in S3 bucket
deploy_to_production:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' # Run for main branch
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 # change if needed
- name: Get PR number from GitHub API
id: pr
run: |
echo "Before pr_number=$PR_NUMBER"
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
$PR_API_URL | jq '.[0].number')
echo "after pr_number=$PR_NUMBER"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to Production Environment
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "inside pr_number=$PR_NUMBER"
echo "Before pr_number=$PR_NUMBER"
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
$PR_API_URL | jq '.[0].number')
echo "after pr_number=$PR_NUMBER"
#aws s3 sync s3://$S3_BUCKET_NAME/MergeRequest/$PR_NUMBER s3://$S3_BUCKET_NAME/production/