Skip to content
Draft
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
109 changes: 109 additions & 0 deletions .github/actions/backend-package-updater/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: 'Backend Package Updater'
description: 'Updates NPM packages in backend assets/ folders from JFrog registry'

inputs:
branch:
description: 'Git branch name to determine dist tag'
required: true
actor:
description: 'GitHub actor who triggered the workflow'
required: true
dot-npmrc:
description: 'Content of .npmrc file for private registry authentication'
required: true

outputs:
pr-number:
description: 'Pull request number (if created)'
value: ${{ steps.create-pr.outputs.pr-number }}

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.15.0

- name: Install github-actions dependencies (without custom .npmrc)
shell: bash
run: |
cd "$GITHUB_ACTION_PATH/../../.."
echo "Installing dependencies in: $(pwd)"
npm ci

- name: Configure .npmrc in backend repo root
shell: bash
run: |
cat > .npmrc << 'NPMRC_EOF'
${{ inputs.dot-npmrc }}
NPMRC_EOF
echo "✓ .npmrc configured in backend repo in $(pwd)"
echo "Debug: .npmrc file contents (sensitive parts masked):"
cat .npmrc | sed 's/\(password\|_auth\|_authToken\)=.*/\1=***/g'

- name: Test npm registry access
shell: bash
run: |
echo "Testing npm access with configured .npmrc..."
npm ping || echo "npm ping failed - checking npm config..."
npm config list
echo ""
echo "Testing npm access from subdirectory..."
cd cf.cplace.training.extended/assets || true
npm config list || true

- name: Run package updater
shell: bash
env:
BRANCH: ${{ inputs.branch }}
ACTOR: ${{ inputs.actor }}
run: npx --yes ts-node "$GITHUB_ACTION_PATH/../../../tools/scripts/backend-package-updater/main.ts"

- name: Check for changes
id: check-changes
shell: bash
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi

- name: Create Pull Request
id: create-pr
if: steps.check-changes.outputs.has_changes == 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
ACTOR: ${{ inputs.actor }}
BRANCH: ${{ inputs.branch }}
run: |
# Read PR description
PR_BODY=$(cat pr-description.md)

# Create branch
BRANCH_NAME="automated/frontend-packages-${BRANCH//\//-}-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH_NAME"

# Commit changes
git add .
git commit -m "Update frontend packages from $BRANCH branch"

# Push branch
git push -u origin "$BRANCH_NAME"

# Create PR with assignee, fallback to no assignee if permission denied
PR_OUTPUT=$(gh pr create \
--title "Update frontend packages from $BRANCH" \
--body "$PR_BODY" \
--assignee "$ACTOR" 2>&1) || \
PR_OUTPUT=$(gh pr create \
--title "Update frontend packages from $BRANCH" \
--body "$PR_BODY" 2>&1)

# Extract PR number
PR_NUMBER=$(echo "$PR_OUTPUT" | grep -oP 'github.com/.+/pull/\K\d+' || echo "")
echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT

echo "Created PR: $PR_OUTPUT"
33 changes: 33 additions & 0 deletions .github/workflow-templates/be/frontend-package-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Frontend Package Update

on:
repository_dispatch:
types: [frontend-packages-published]

jobs:
update-packages:
name: Update Frontend Packages
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.branch }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"


- name: Update packages
uses: collaborationFactory/github-actions/.github/actions/backend-package-updater@master
with:
branch: ${{ github.event.client_payload.branch }}
actor: ${{ github.event.client_payload.actor }}
dot-npmrc: ${{ secrets.DOT_NPMRC }}
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-check-upmerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions: write-all

jobs:
check-upmerge:
uses: collaborationFactory/github-actions/.github/workflows/fe-check-upmerge.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-check-upmerge.yml@feature/automate-frontend-pkg-integration
secrets:
SLACK_TOKEN_UPMERGE: ${{ secrets.SLACK_TOKEN_UPMERGE }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-cleanup-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions: write-all

jobs:
cleanup-snapshots:
uses: collaborationFactory/github-actions/.github/workflows/fe-cleanup-snapshots.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-cleanup-snapshots.yml@feature/automate-frontend-pkg-integration
secrets:
JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}
JFROG_URL: ${{ secrets.JFROG_URL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
check-licenses:
uses: collaborationFactory/github-actions/.github/workflows/fe-licenses.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-licenses.yml@feature/automate-frontend-pkg-integration
with:
FOSS_DIST: dist
CUSTOM_LICENSES_JSON: custom-licenses/custom-licenses.json
Expand Down
8 changes: 4 additions & 4 deletions .github/workflow-templates/fe/fe-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
install-deps:
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
secrets:
Expand All @@ -22,7 +22,7 @@ jobs:
# This job is only needed in case you are using Percy
e2e-tests:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}
Expand All @@ -31,14 +31,14 @@ jobs:

build:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}

snapshot:
needs: build
uses: collaborationFactory/github-actions/.github/workflows/fe-snapshot.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-snapshot.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions: write-all

jobs:
remove-artifacts:
uses: collaborationFactory/github-actions/.github/workflows/fe-pr-close.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-pr-close.yml@feature/automate-frontend-pkg-integration
with:
GHA_BASE: ${{ github.event.pull_request.base.ref }}
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-pr-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions: write-all

jobs:
publish-pr-snapshot:
uses: collaborationFactory/github-actions/.github/workflows/fe-pr-snapshot.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-pr-snapshot.yml@feature/automate-frontend-pkg-integration
with:
GHA_BASE: ${{ github.event.pull_request.base.ref }}
secrets:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflow-templates/fe/fe-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ env:

jobs:
install-deps:
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ${{ github.event.pull_request.head.ref }}
secrets:
DOT_NPMRC: ${{ secrets.DOT_NPMRC }}

build:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ${{ github.event.pull_request.head.ref }}
GHA_BASE: ${{ github.event.pull_request.base.ref }}

code-quality:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-code-quality.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-code-quality.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ${{ github.event.pull_request.head.ref }}
GHA_BASE: ${{ github.event.pull_request.base.ref }}
e2e:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ${{ github.event.pull_request.head.ref }}
GHA_BASE: ${{ github.event.pull_request.base.ref }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflow-templates/fe/fe-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ env:

jobs:
install-deps:
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-install-deps.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
secrets:
DOT_NPMRC: ${{ secrets.DOT_NPMRC }}

e2e-tests:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-e2e.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}
Expand All @@ -29,14 +29,14 @@ jobs:

build:
needs: install-deps
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-build.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}

tag:
needs: [build, e2e-tests]
uses: collaborationFactory/github-actions/.github/workflows/fe-tag.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-tag.yml@feature/automate-frontend-pkg-integration
with:
GHA_REF: ''
GHA_BASE: ${{ github.event.before }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow-templates/fe/fe-tag-pushed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
release-version:
uses: collaborationFactory/github-actions/.github/workflows/fe-release.yml@master
uses: collaborationFactory/github-actions/.github/workflows/fe-release.yml@feature/automate-frontend-pkg-integration
secrets:
JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}
JFROG_URL: ${{ secrets.JFROG_URL }}
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/be-package-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Backend Package Update

on:
repository_dispatch:
types: [frontend-packages-published]
secrets:
DOT_NPMRC:
required: true

jobs:
update-packages:
name: Update Frontend Packages
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.branch }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"

- name: Update packages
uses: collaborationFactory/github-actions/.github/actions/backend-package-updater@feature/automate-frontend-pkg-integration
with:
branch: ${{ github.event.client_payload.branch }}
actor: ${{ github.event.client_payload.actor }}
2 changes: 1 addition & 1 deletion .github/workflows/fe-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: git fetch origin ${{ inputs.GHA_BASE }}:${{ inputs.GHA_BASE }} || true

- name: Build and Storybook
uses: collaborationFactory/github-actions/.github/actions/run-many@master
uses: collaborationFactory/github-actions/.github/actions/run-many@feature/automate-frontend-pkg-integration
with:
target: ${{ matrix.target }}
jobIndex: ${{ matrix.jobIndex }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fe-check-upmerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: check if upmerge is necessary and post to slack
uses: collaborationFactory/github-actions/.github/actions/upmerge@master
uses: collaborationFactory/github-actions/.github/actions/upmerge@feature/automate-frontend-pkg-integration
env:
SLACK_TOKEN_UPMERGE: ${{ secrets.SLACK_TOKEN_UPMERGE }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fe-cleanup-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
dot-npmrc: ${{ secrets.DOT_NPMRC }}

- name: Cleanup Snapshot Artifacts
uses: collaborationFactory/github-actions/.github/actions/snapshots@master
uses: collaborationFactory/github-actions/.github/actions/snapshots@feature/automate-frontend-pkg-integration
env:
JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}
JFROG_URL: ${{ secrets.JFROG_URL }}
Expand Down
Loading