Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add gh workflow for raising pr for constants #1832

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Generated constants are not up-to-date. Run 'npm run generate:constants' and commit the changes.";
echo "Here are the differences:";
git diff || true 2>&1;
exit 1;
else
echo "Git state is clean.";
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/raise-pr-for-constants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Raise PR for Destination Constants

on:
push:
branches:
- develop

permissions:
contents: write
pull-requests: write

env:
BRANCH_NAME: fix/gh-update-destinations-ts
koladilip marked this conversation as resolved.
Show resolved Hide resolved
SRC_FILE: generated/Destinations.ts
DEST_PATH: packages/analytics-js-common/src/constants/integrations/Destinations.ts

jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
pr_required: ${{ steps.compare_files.outputs.pr_required }}
steps:
- name: Checkout Source Repo
uses: actions/checkout@v4
with:
ref: develop

- name: Checkout Destination Repo
run: |
DEST_REPO="rudderlabs/rudder-sdk-js"
git clone https://github.com/${DEST_REPO}.git dest-repo || exit 1
cd dest-repo
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
git checkout ${{ env.BRANCH_NAME }} || git checkout -b ${{ env.BRANCH_NAME }}

- name: Compare Destinations.ts
id: compare_files
run: |
if cmp -s "${{ env.SRC_FILE }}" "dest-repo/${{ env.DEST_PATH }}"; then
echo "No changes detected." > "result.txt"
echo "pr_required=false" >> $GITHUB_OUTPUT
else
echo "Changes detected." > "result.txt"
echo "pr_required=true" >> $GITHUB_OUTPUT
fi
koladilip marked this conversation as resolved.
Show resolved Hide resolved

raise_pr:
needs: check_changes
if: needs.check_changes.outputs.pr_required == 'true'
runs-on: ubuntu-latest
steps:
- name: Commit and Push Changes
run: |
cd dest-repo
cp "../generated/Destinations.ts" "packages/analytics-js-common/src/constants/integrations/Destinations.ts"
git add packages/analytics-js-common/src/constants/integrations/Destinations.ts
git commit -m "fix: update destinations.ts"
git push origin ${{ env.BRANCH_NAME }}

- name: Create or Update PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd dest-repo
EXISTING_PR=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number --jq ".[0].number")
if [ -z "$EXISTING_PR" ]; then
gh pr create \
--title "fix: update destination constants" \
--body "This PR updates the destination constants file.

**Changes:**
- Updated \`Destinations.ts\` with latest constants

This PR was automatically generated by GitHub Actions." \
--label "automated,dependencies"
else
echo "PR already exists: $EXISTING_PR"
fi
4 changes: 2 additions & 2 deletions generated/Destinations.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.dart.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.dart
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.dart

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

class Destinations {
Expand Down
4 changes: 2 additions & 2 deletions generated/Destinations.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.java.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.java
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.java

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

public class Destinations {
Expand Down
4 changes: 2 additions & 2 deletions generated/Destinations.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.kt.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.kt
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.kt

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

object Destinations {
Expand Down
4 changes: 2 additions & 2 deletions generated/Destinations.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.m.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.m
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.m

NOTE: Containly only constants for device mode destinations */
NOTE: Contains only constants for device mode destinations */

#import <Foundation/Foundation.h>

Expand Down
4 changes: 2 additions & 2 deletions generated/Destinations.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.swift.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.swift
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.swift

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

struct Destinations {
Expand Down
4 changes: 2 additions & 2 deletions generated/Destinations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.ts.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.ts
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.ts

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/
export const ACTIVE_CAMPAIGN_NAME = 'ACTIVE_CAMPAIGN';
export const ACTIVE_CAMPAIGN_DISPLAY_NAME = 'ActiveCampaign';
Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.dart.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.dart.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.dart
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.dart

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

class Destinations {
Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.java.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.java.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.java
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.java

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

public class Destinations {
Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.kt.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.kt.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.kt
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.kt

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

object Destinations {
Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.m.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.m.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.m
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.m

NOTE: Containly only constants for device mode destinations */
NOTE: Contains only constants for device mode destinations */

#import <Foundation/Foundation.h>

Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.swift.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.swift.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.swift
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.swift

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/

struct Destinations {
Expand Down
4 changes: 2 additions & 2 deletions templates/Destinations.ts.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
GENERATED - DO NOT EDIT
This file is generated from the templates/Destinations.ts.template file.
Orginal file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.ts
Original file: https://github.com/rudderlabs/rudder-integrations-config/blob/develop/generated/Destinations.ts

NOTE: Containly only constants for device mode destinations
NOTE: Contains only constants for device mode destinations
*/
${
destinations.map((dest) =>
Expand Down
Loading