Skip to content

Update package_installers.yml #5

Update package_installers.yml

Update package_installers.yml #5

name: Fetch Commits and create issue with details
# on:
# schedule:
# - cron: '* * * * *' # Runs daily at midnight UTC
on:
push:
branches: [ master ]
jobs:
fetch-and-create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository gtfs-validator
uses: actions/[email protected]
with:
ref: master
fetch-depth: 0
token: ${{ secrets.FRED_PERSONAL_GITHUB_TOKEN }}
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install dependencies
run: npm install @actions/github
- name: Set up Git
id: git-setup
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
echo "user_name=github-actions[bot]" >> $GITHUB_OUTPUT
echo "user_email=41898282+github-actions[bot]@users.noreply.github.com" >> $GITHUB_OUTPUT
echo "reviewer=emmambd" >> $GITHUB_OUTPUT
echo "assigned=fredericsimard" >> $GITHUB_OUTPUT
# Comma-separated list of reviewers and assignees
- name: Calculate Dates
id: dates
run: |
echo "yesterday=$(date -d '-1 day' '+%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Extract and process JSON
id: process_json
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.request('GET /repos/google/transit/commits', {
owner: 'fredericsimard',
repo: 'gtfs-validator-fork',
path: 'gtfs/spec/en/reference.md',
since: '2023-08-01T00:00:00Z',
});
const commits = response.data;
core.setOutput('commits_data', commits);
core.setOutput('commits_length', commits.length);
if (commits.length > 0) {
const extractedData = commits.map(item => ({
author: item.commit.author.name,
username: item.author.login,
date: item.commit.author.date,
message: item.commit.message.replace(/\n\s*\n/g, '\n'),
html_url: item.html_url
}));
const formattedExtractedData = extractedData.map((item, index) => {
const dateObjectUTC = new Date(item.date);
const dateObjectETC = new Date(dateObjectUTC.toLocaleString('en-US', { timeZone: 'America/Toronto' }));
const formattedDateETC = dateObjectETC.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
const formattedTimeUTC = dateObjectUTC.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
});
const formattedTimeETC = dateObjectETC.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
});
const counter = index + 1;
return `# \`Commit Nº ${counter}\`\n## AUTHOR × DATE\n* **${item.author}** ( _${item.username}_ )\n* **${formattedDateETC}** @ ${formattedTimeETC} ETC (${formattedTimeUTC})\n## MESSAGE\n\`\`\`\n${item.message}\n\`\`\`\n## FILES CHANGED\n> ### ${item.html_url}\n\n\`\`\`\n${item.html_url}\n\`\`\`\n---\n`;
}).join('\n');
core.setOutput('extracted_data', formattedExtractedData);
core.setOutput('condition_met', 'true');
} else {
core.setOutput('extracted_data', '');
core.setOutput('condition_met', 'false');
}
# core.setOutput('extracted_data', JSON.stringify(extractedData));
- name: Create Issue
if: steps.process_json.outputs.condition_met == 'true'
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.FRED_PERSONAL_GITHUB_TOKEN }}
title: ${{ steps.dates.outputs.today }} — ${{ steps.process_json.outputs.commits_length }} new commit(s) made to `reference.md` in Google Transit's repo
body: |
${{ steps.process_json.outputs.extracted_data }}
assignees: ${{ steps.git-setup.outputs.assigned }}