-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from PtPrashantTripathi/PtPrashantTripathi-pat…
…ch-1 Update cd.yml
- Loading branch information
Showing
2 changed files
with
84 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,71 @@ | ||
# Workflow for deploying static content to GitHub Pages | ||
|
||
name: continuous-delivery | ||
name: CD | ||
|
||
on: | ||
# Trigger this workflow on pushes to the 'main' branch, but only when changes are made in the 'FRONTEND' folder | ||
# Trigger workflow on pushes to the 'main' branch, limited to changes in 'FRONTEND' or workflow files | ||
push: | ||
branches: ["main"] | ||
branches: | ||
- main | ||
paths: | ||
- 'FRONTEND/**' | ||
- '.github/workflows/**' | ||
|
||
# Allow this workflow to be triggered manually from the Actions tab | ||
# Allow manual trigger from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Set permissions for the GITHUB_TOKEN to enable reading repository content and deploying to GitHub Pages | ||
# Set permissions for the GITHUB_TOKEN to read content and deploy to GitHub Pages | ||
permissions: | ||
contents: read # Read access to the repository content | ||
pages: write # Write access to GitHub Pages for deployment | ||
id-token: write # Generate an ID token required for deploying to GitHub Pages | ||
contents: read # Read access to repository content | ||
pages: write # Write access to GitHub Pages | ||
id-token: write # ID token for secure Pages deployment | ||
|
||
# Configure concurrency to ensure only one deployment runs at a time; do not cancel in-progress deployments | ||
# Ensure only one deployment runs at a time and do not cancel in-progress jobs | ||
concurrency: | ||
group: "pages" # Use the "pages" group for deployments to GitHub Pages | ||
cancel-in-progress: false # Allow ongoing deployments to finish without interruption | ||
group: pages-deployments | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Define a single deployment job for deploying the site to GitHub Pages | ||
deploy: | ||
# Set environment details for the deployment | ||
# Environment configuration for GitHub Pages deployment | ||
environment: | ||
name: github-pages # The environment name to deploy to | ||
url: ${{ steps.deployment.outputs.page_url }} # URL of the deployed GitHub Pages site | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
# Use the latest Ubuntu runner for the deployment | ||
# Use the latest stable Ubuntu runner | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the repository to access the files for deployment | ||
- name: Checkout | ||
# Step 1: Checkout the repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 # Limit fetch to improve job speed | ||
|
||
# Step 2: Setup GitHub Pages configuration for the deployment | ||
- name: Setup Pages | ||
# Step 2: Setup Pages for deployment | ||
- name: Setup GitHub Pages | ||
uses: actions/configure-pages@v5 | ||
|
||
# Step 2.5: Replace apiPath in render.js | ||
- name: Replace apiPath in render.js | ||
# Step 2.5: Replace local API path with the live API URL in 'render.js' | ||
- name: Update API Path in render.js | ||
run: | | ||
# Dynamically construct the API URL using the GitHub username and repo name | ||
API_URL="https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/DATA/API/API_data.json" | ||
echo $API_URL | ||
# Replace the local URL in render.js with the dynamic API URL | ||
sed -i 's|../DATA/API/API_data.json|$API_URL|' ./FRONTEND/asset/js/render.js | ||
# Step 3: Upload the content of the 'FRONTEND' folder as an artifact for deployment | ||
- name: Upload artifact | ||
echo "Replacing local API path with live URL..." | ||
sed -i 's|../DATA/API/API_data.json|https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/DATA/API/API_data.json|' ./FRONTEND/asset/js/render.js | ||
# Step 3: Upload static site content from 'FRONTEND' directory as an artifact | ||
- name: Upload static site content | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: './FRONTEND/' # Path to the folder containing static content to deploy | ||
path: './FRONTEND/' # Path to frontend static files | ||
retention-days: 5 # Retain artifacts for 5 days | ||
|
||
# Step 4: Deploy the uploaded artifact to GitHub Pages | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
|
||
# Step 5: Verify successful deployment (Optional) | ||
- name: Verify deployment | ||
run: | | ||
DEPLOY_URL="${{ steps.deployment.outputs.page_url }}" | ||
echo "Deployed site URL: $DEPLOY_URL" | ||
curl -I $DEPLOY_URL | grep "200 OK" || echo "Warning: Deployment may have failed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,83 @@ | ||
name: continuous-integration | ||
# Continuous Integration workflow for automated monthly data updates | ||
name: CI | ||
|
||
on: | ||
# Schedule to run on the 1st day of every month at midnight UTC | ||
schedule: | ||
- cron: "0 0 1 * *" # every 1st day of the month | ||
- cron: "0 0 1 * *" | ||
|
||
# Allow manual trigger from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update: | ||
# Use the latest Ubuntu runner | ||
runs-on: ubuntu-latest | ||
|
||
# Define environment variables | ||
env: | ||
RELEASE_DATE: "" | ||
PROJECT_DIR: ${{ github.workspace }} | ||
RELEASE_DATE: "" # Placeholder for release date, set dynamically during the job | ||
PROJECT_DIR: ${{ github.workspace }} # Set project directory to the current GitHub workspace | ||
|
||
steps: | ||
# Step 1: Checkout the repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 # Fetch only the latest commit for efficiency | ||
|
||
# Step 2: Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
python-version: "3.x" # Use the latest stable Python 3.x version | ||
|
||
# Step 3: Set the release date for the update | ||
- name: Set release date | ||
run: | | ||
echo "RELEASE_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV} | ||
# Step 4: Install dependencies from the requirements file and locally (if applicable) | ||
- name: Install dependencies | ||
run: | | ||
pip install -e . | ||
pip install -r requirements.txt | ||
echo "Installing Python dependencies..." | ||
pip install -e . # Install local package | ||
pip install -r requirements.txt # Install required dependencies | ||
# Step 5: Execute Jupyter notebooks via a custom script | ||
- name: Run Jupyter notebooks | ||
run: bash all_runner.sh | ||
run: | | ||
echo "Running all Jupyter notebooks..." | ||
bash all_runner.sh | ||
# Step 6: Create a pull request with the data updates | ||
- name: Create Pull Request | ||
id: cpr | ||
id: cpr # Set an ID to reference outputs | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "Data update as on ${{ env.RELEASE_DATE }}" | ||
token: ${{ secrets.GITHUB_TOKEN }} # Use the repo's GitHub token for authentication | ||
commit-message: "Data update as of ${{ env.RELEASE_DATE }}" | ||
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | ||
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | ||
signoff: false | ||
base: main | ||
branch: data-update | ||
delete-branch: true | ||
title: "[PanditBot] Updating Repos Data ${{ env.RELEASE_DATE }}" | ||
base: main # Create the PR against the main branch | ||
branch: data-update # Create a new branch for the updates | ||
delete-branch: true # Delete the branch after the PR is merged | ||
title: "[PanditBot] Updating Repo Data ${{ env.RELEASE_DATE }}" | ||
body: | | ||
This PR contains the data updates. | ||
- "Updated with *${{ env.RELEASE_DATE }}*" | ||
This PR contains the automated data updates. | ||
- Updated as of *${{ env.RELEASE_DATE }}*. | ||
labels: | | ||
report | ||
automated pr | ||
assignees: ptprashanttripathi | ||
reviewers: ptprashanttripathi | ||
draft: false | ||
automated-pr | ||
assignees: ptprashanttripathi # Assign the PR to yourself | ||
reviewers: ptprashanttripathi # Set yourself as the reviewer | ||
draft: false # Mark the PR as ready for review | ||
|
||
- name: Check outputs | ||
# Step 7: Log outputs for visibility (PR number and URL) | ||
- name: Log PR Details | ||
if: ${{ steps.cpr.outputs.pull-request-number }} | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" | ||
echo "Pull Request Number: ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL: ${{ steps.cpr.outputs.pull-request-url }}" | ||