-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
94 additions
and
19 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,3 +1,83 @@ | ||
#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 | ||
# git push --set-upstream origin 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 | ||
# | ||
# - name: Create pull request to main | ||
# if: env.changes_detected == 'true' | ||
# run: | | ||
# echo -e "Scheduled banner update ${{ github.event.issue.number }}. 🔔 @slesaad\nAutomatically created by Github action" > msg | ||
# gh pr create -H staging -B main --title 'Update banner for #${{ github.event.issue.number }}' --body-file msg | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# | ||
# | ||
|
||
name: Update banner | ||
|
||
on: | ||
|
@@ -50,34 +130,29 @@ jobs: | |
- name: Checkout or Create Staging Branch | ||
run: | | ||
git fetch | ||
if git show-ref --verify --quiet refs/heads/staging; then | ||
if git show-ref --verify --quiet refs/remotes/origin/staging; then | ||
git checkout staging | ||
git pull origin staging | ||
else | ||
git checkout -b staging | ||
git push --set-upstream origin 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 | ||
# | ||
# - name: Create pull request to main | ||
# if: env.changes_detected == 'true' | ||
# run: | | ||
# echo -e "Scheduled banner update ${{ github.event.issue.number }}. 🔔 @slesaad\nAutomatically created by Github action" > msg | ||
# gh pr create -H staging -B main --title 'Update banner for #${{ github.event.issue.number }}' --body-file msg | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Commit files | ||
id: commit-changes | ||
run: | | ||
git add banner.json | ||
git diff-index --quiet HEAD || echo "changes_detected=true" >> $GITHUB_ENV | ||
git commit -m "Updating banner for #${{ github.event.issue.number }}" || echo "No changes to commit" | ||
- name: Push changes | ||
if: env.changes_detected == 'true' | ||
run: | | ||
git pull --rebase --strategy-option=theirs origin staging | ||
git push --set-upstream origin staging | ||
- name: Create pull request to main | ||
if: success() | ||
if: env.changes_detected == 'true' | ||
run: | | ||
echo -e "Scheduled banner update ${{ github.event.issue.number }}. 🔔 @slesaad\nAutomatically created by Github action" > msg | ||
gh pr create -H staging -B main --title 'Update banner for #${{ github.event.issue.number }}' --body-file msg | ||
|