test 3 #36
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
#name: Update banner | |
# | |
#on: | |
# issues: | |
# # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues | |
# types: | |
# - opened | |
# - edited | |
# - reopened | |
# - labeled | |
# | |
#jobs: | |
# update_files: | |
# runs-on: ubuntu-latest | |
# name: Convert New Issue to GHG Dashboard Dynamic Data | |
# # require a `banner` label for moderation | |
# if: contains( github.event.issue.labels.*.name, 'banner') | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# - name: GitHub Issue to JSON | |
# uses: zachleat/[email protected] | |
# with: | |
# # This tells the action which GitHub Issue Form template file to use | |
# issue-template: "banner.yaml" | |
# # This controls which property we use to key the file name hash off of (values should be unique in your data set) | |
# hash-property-name: "url" | |
# | |
# - name: Update the existing files | |
# run: python banner.py | |
# | |
# - name: Commit files | |
# run: | | |
# git config --local user.email "[email protected]" | |
# git config --local user.name "GitHub Action" | |
# git checkout -b staging | |
# git add banner.json | |
# git commit -m "Updating banner for #${{ env.IssueNumber }}" | |
# git push | |
name: Update banner | |
on: | |
issues: | |
types: | |
- opened | |
- edited | |
- reopened | |
- labeled | |
jobs: | |
update_files: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
name: Convert New Issue to GHG Dashboard Dynamic Data | |
if: contains(github.event.issue.labels.*.name, 'banner') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: GitHub Issue to JSON | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const issue = context.payload.issue; | |
const jsonContent = JSON.stringify(issue, null, 2); | |
if (!fs.existsSync('_data')){ | |
fs.mkdirSync('_data'); | |
} | |
fs.writeFileSync('_data/issue.json', jsonContent); | |
console.log('Issue converted to JSON and written to _data/issue.json'); | |
console.log('Content:', jsonContent); | |
- name: List _data directory | |
run: ls -l _data | |
- name: Update the existing files | |
run: python scripts/banner.py | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Checkout or Create Staging Branch | |
run: | | |
git fetch | |
if git show-ref --verify --quiet refs/heads/staging; then | |
git checkout staging | |
git pull origin staging | |
else | |
git checkout -b staging | |
fi | |
- name: Commit files | |
run: | | |
git add banner.json | |
git commit -m "Updating banner for #${{ github.event.issue.number }}" | |
- name: Push changes | |
run: | | |
git pull --rebase --strategy-option=theirs origin staging | |
git push --set-upstream origin staging |