Skip to content
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3cf8860
Moved git auth after auth is set
fredericsimard Feb 20, 2025
96310dc
Added permissions for the bot
fredericsimard Feb 20, 2025
44d2b6e
test adding permissions
davidgamez Feb 20, 2025
6430284
remove credentials from workflow
davidgamez Feb 20, 2025
b6f8695
use default GH token
davidgamez Feb 20, 2025
ee070f1
add echos
davidgamez Feb 20, 2025
074caf3
change push command
davidgamez Feb 20, 2025
d2dc573
stop tracking main branch from new branch
davidgamez Feb 20, 2025
94ff6d6
change push flow
davidgamez Feb 20, 2025
42bdc72
Automated commit — New/Updated feed(s)
davidgamez Feb 24, 2025
49f9846
Merge branch 'main' into fix-add-new-feeds-2025-02-20
fredericsimard Feb 24, 2025
4468c41
Automated commit — New/Updated feed(s)
davidgamez Feb 24, 2025
5f17605
test only push
davidgamez Feb 24, 2025
b42a33d
add upstream and logs
davidgamez Feb 24, 2025
41c6910
add permissions
davidgamez Feb 24, 2025
530733f
revert changes
davidgamez Feb 24, 2025
87c1a03
more logs
davidgamez Feb 24, 2025
b55cdd6
more logs
davidgamez Feb 24, 2025
2e68a50
more logs
davidgamez Feb 24, 2025
b652205
more logs
davidgamez Feb 24, 2025
a46008f
more logs
davidgamez Feb 24, 2025
5f52d86
more logs
davidgamez Feb 24, 2025
e2f1997
more logs
davidgamez Feb 24, 2025
2d75b84
test awk
davidgamez Feb 24, 2025
71150de
test awk
davidgamez Feb 24, 2025
4339a3b
cleanup
davidgamez Feb 24, 2025
95bbf65
delete check gh
davidgamez Feb 24, 2025
debbdf2
Merge branch 'main' into fix-add-new-feeds-2025-02-20
davidgamez Feb 25, 2025
2486258
Merge branch 'main' into fix-add-new-feeds-2025-02-20
davidgamez Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions .github/workflows/add_new_or_updated_feeds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
# schedule:
# - cron: '55 3 * * *' # Run every night

permissions:
contents: write # Permissions to read/write content like code
pull-requests: write # Permissions to create/merge pull requests

env:
DATE_FORMAT: "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}|[0-9]{4}-[0-9]{2}-[0-9]{2}" # this is the format we need to compare dates between the CSV and the local system.
DATE_FORMAT_DESIRED: "MM/dd/yyyy"
Expand All @@ -18,8 +22,7 @@ env:

jobs:
add-new-updated-feeds:
runs-on: ubuntu-22.04

runs-on: ubuntu-latest
steps:
- name: Setup global variables
id: global_vars
Expand All @@ -43,7 +46,6 @@ jobs:
export-env: true # Export loaded secrets as environment variables
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
CREDENTIALS: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/ifkeehu5gzi7wy5ub5qvwkaire/credential"
# The URL to obtain the csv file with the data of the google form. Taken from the "GiHub Actions — URLs" entry in 1password
CSV_URL: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/qkn5esttmtojawglm4l6t2bqaa/al2gjfhiuddabkp7o26hszuvia"
SLACK_WEBHOOK_URL: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/Slack webhook URLs/rdpfgrmnbxqaelgi5oky3lryz4/internal-add-feeds"
Expand All @@ -54,7 +56,6 @@ jobs:
with:
ref: ${{ env.BASE }}
fetch-depth: 0
token: ${{ env.CREDENTIALS }}

- name: Create new branch
shell: bash
Expand Down Expand Up @@ -112,49 +113,44 @@ jobs:
echo -e "\n\n"
git status

- name: Checking GitHub CLI and Git Authentication
run: |
# Check GitHub CLI authentication
gh auth status

# Check Git authentication
git config --get user.name
git config --get user.email
env:
GH_TOKEN: ${{ env.CREDENTIALS }}
GITHUB_TOKEN: ${{ env.CREDENTIALS }}
shell: bash


- name: Commit, push, and create PR
id: commit-push-create-pr
if: steps.process-csv.outputs.PYTHON_SCRIPT_ARGS != ''
run: |
BRANCH_NAME=${{ steps.create_branch_name.outputs.BRANCH }}

# Fetch the latest changes from main
#git fetch origin main
echo "fetching from origin"
git fetch origin main

# Create or reset the branch to the current main
echo "Create or reset the branch to the current main"
git checkout -B "$BRANCH_NAME" origin/main

# Configure git
git config --global user.name "${{ env.USERNAME }}"
git config --global user.email "${{ env.USERNAME_EMAIL }}"
# Add changes

echo "Add changes"
git add .
echo "----------"

# Count new files
NEW_FILE_COUNT=$(git status --porcelain | grep -c "^A")

# Commit changes
echo "Check commit"
git status --porcelain
echo "----------"

echo "Count new files"
NEW_FILE_COUNT=$(git status --porcelain | awk '$1 == "A" {count++} END {print count+0}')
echo "----------"

echo "Commit changes: $NEW_FILE_COUNT"
git commit -m "Automated commit — New/Updated feed(s)"

# Force push changes to the branch
echo "----------"

echo "Force push changes to the branch"
git push -f origin "$BRANCH_NAME" || (echo "Git push failed!" && git remote -v && git branch -vv && exit 1)

# Check if a PR already exists
echo "----------"

echo "Check if a PR already exists"
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number -q '.[0].number')

if [ -n "$EXISTING_PR" ]; then
Expand All @@ -173,8 +169,8 @@ jobs:
echo "pr-url=$PR_URL" >> $GITHUB_OUTPUT
echo "new-file-count=$NEW_FILE_COUNT" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ env.CREDENTIALS }}
GITHUB_TOKEN: ${{ env.CREDENTIALS }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash

- name: Post notification in Slack channel of update
Expand Down