Skip to content

fix: update workflow configurations #2

fix: update workflow configurations

fix: update workflow configurations #2

name: Integrate Develop to Staging
on:
push:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
create-or-update-pr:
name: Create or Update PR to Staging
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.10.0'
- name: Check for existing PR
id: check-pr
run: |
EXISTING_PR=$(gh pr list --base staging --head develop --json number --jq '.[0].number' || echo "")
if [ -n "$EXISTING_PR" ]; then
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT
echo "Found existing PR #$EXISTING_PR"
else
echo "pr_exists=false" >> $GITHUB_OUTPUT
echo "No existing PR found"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get commit information
id: commit-info
run: |
# Get the latest commits from develop that aren't in staging
COMMITS=$(git log --pretty=format:"- %s (%h)" origin/staging..HEAD | head -20)
COMMIT_COUNT=$(git rev-list --count origin/staging..HEAD)
# Escape for GitHub Actions output
COMMITS="${COMMITS//'%'/'%25'}"
COMMITS="${COMMITS//$'\n'/'%0A'}"
COMMITS="${COMMITS//$'\r'/'%0D'}"
echo "commits<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT
# Get timestamp
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
- name: Create PR to staging
if: steps.check-pr.outputs.pr_exists == 'false'
run: |
gh pr create \
--base staging \
--head develop \
--title "🔄 Integrate develop → staging" \
--body "## 🚀 Integration from develop to staging
### 📊 Summary
- **Commits**: ${{ steps.commit-info.outputs.commit_count }} new commits

Check failure on line 77 in .github/workflows/integrate-develop.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/integrate-develop.yml

Invalid workflow file

You have an error in your yaml syntax on line 77
- **Created**: ${{ steps.commit-info.outputs.timestamp }}
- **Auto-generated**: This PR was automatically created by the integration workflow
### 📝 Recent Commits
${{ steps.commit-info.outputs.commits }}
### 🔍 What happens next?
1. Review the changes in this PR
2. Run any necessary QA tests
3. When approved and merged, the staging workflow will:
- Check for changesets
- If found, create beta releases
- Automatically create a PR to main
### ⚡ Notes
- This PR will be automatically updated with new commits to develop
- Multiple features can accumulate in this single PR
- Approval triggers the beta release process" \
--label "integration" \
--label "automated"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update existing PR
if: steps.check-pr.outputs.pr_exists == 'true'
run: |
# Update PR title with commit count
gh pr edit ${{ steps.check-pr.outputs.pr_number }} \
--title "🔄 Integrate develop → staging (${{ steps.commit-info.outputs.commit_count }} commits)"
# Get current PR body
CURRENT_BODY=$(gh pr view ${{ steps.check-pr.outputs.pr_number }} --json body --jq '.body')
# Create updated section
UPDATED_SECTION="### 🔄 Last Updated: ${{ steps.commit-info.outputs.timestamp }}
**New commits**: ${{ steps.commit-info.outputs.commit_count }}
### 📝 Recent Commits
${{ steps.commit-info.outputs.commits }}"
# Update or append the updated section
if echo "$CURRENT_BODY" | grep -q "### 🔄 Last Updated:"; then
# Replace existing update section
NEW_BODY=$(echo "$CURRENT_BODY" | sed '/### 🔄 Last Updated:/,/### 📝 Recent Commits/d' | sed '/^$/d')
NEW_BODY="$NEW_BODY
$UPDATED_SECTION"
else
# Append update section
NEW_BODY="$CURRENT_BODY
---
$UPDATED_SECTION"
fi
# Update PR body
gh pr edit ${{ steps.check-pr.outputs.pr_number }} --body "$NEW_BODY"
# Add labels
gh pr edit ${{ steps.check-pr.outputs.pr_number }} \
--add-label "auto-updated" \
--add-label "needs-review"
# Set as ready for review
gh pr ready ${{ steps.check-pr.outputs.pr_number }} || true
echo "✅ Updated PR #${{ steps.check-pr.outputs.pr_number }} with ${{ steps.commit-info.outputs.commit_count }} new commits"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}