Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
update
  • Loading branch information
seaona committed Jul 8, 2025
commit 4db842b9afec4a06e946198739a4f00ea9884111
105 changes: 0 additions & 105 deletions .github/workflows/log-daily-pr-merges.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/log-merge-group-success.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Log merge group success

on:
workflow_call:
secrets:
GOOGLE_APPLICATION_CREDENTIALS:
required: true
GOOGLE_SERVICE_ACCOUNT:
required: true
SPREADSHEET_ID:
required: true
SHEET_NAME:
required: true
workflow_dispatch:

jobs:
log-merge-group-success:
name: Log merge group success
runs-on: ubuntu-latest
steps:
- name: Download oauth2l
run: |
curl --silent https://storage.googleapis.com/oauth2l/1.3.2/linux_amd64.tgz | tar xz
echo "$PWD/linux_amd64" >> "$GITHUB_PATH"

- name: Create service_account.json
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
run: |
echo "$GOOGLE_SERVICE_ACCOUNT" > "$GOOGLE_APPLICATION_CREDENTIALS"

- name: Write data to google sheets
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
SPREADSHEET_ID: ${{ secrets.SPREADSHEET_ID }}
SHEET_NAME: ${{ secrets.SHEET_NAME }}
run: |
current_date=$(date +%Y-%m-%d)
token=$(oauth2l fetch --scope https://www.googleapis.com/auth/spreadsheets)
spreadsheet_data=$(curl --silent --header "Authorization: Bearer $token" https://sheets.googleapis.com/v4/spreadsheets/"$SPREADSHEET_ID"/values/"$SHEET_NAME"!A:C)
current_date_index=$(echo "$spreadsheet_data" | jq --arg current_date "$current_date" '(.values | map(.[0])) | (index($current_date) | if . == null then null else . + 1 end)')
current_number_of_successes=$(echo "$spreadsheet_data" | jq --arg current_date "$current_date" '(.values[] | select(.[0] == $current_date) | .[2] | tonumber) // null')
if [ "$current_date_index" == "null" ]; then
curl --silent --header "Authorization: Bearer $token" --header "Content-Type: application/json" --request POST --data "{\"values\":[[\"$current_date\", \"\", 1]]}" https://sheets.googleapis.com/v4/spreadsheets/"$SPREADSHEET_ID"/values/"$SHEET_NAME"!A:C:append?valueInputOption=USER_ENTERED
else
curl --silent --header "Authorization: Bearer $token" --header "Content-Type: application/json" --request PUT --data "{\"values\":[[\"$current_date\", \"\", $(("$current_number_of_successes" + 1))]]}" https://sheets.googleapis.com/v4/spreadsheets/"$SPREADSHEET_ID"/values/"$SHEET_NAME"!A"$current_date_index":C"$current_date_index"?valueInputOption=USER_ENTERED
fi
Loading