Skip to content

changes github action #10

changes github action

changes github action #10

name: Create Pull Request to DevPortal's repo
on: workflow_dispatch
# push:
# branches:
# - main
# paths:
# - "apps/docs/pages/APIs/wallet-api/*"
# - "apps/docs/pages/docs/discover/*"
jobs:
syncAndCreatePR:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:

Check failure on line 16 in .github/workflows/sync_doc_devportal.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/sync_doc_devportal.yml

Invalid workflow file

You have an error in your yaml syntax on line 16
ref: ${{ github.head_ref }}
token: ${{ secrets.DEVELOPER_PORTAL_CI }}
- name: Checkout repository
uses: actions/setup-node@v2
with:
node-version: "lts/*"
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Sync files to the other repository and create Pull Request
env:
DEVELOPER_PORTAL_CI_TOKEN: ${{ secrets.DEVELOPER_PORTAL_CI }}
SOURCE_REPO_NAME: "wallet-api"
SOURCE_REPO: "github.com/LedgerHQ/wallet-api"
SOURCE_FILE_PATH_1: "apps/docs/pages/APIs/wallet-api"
SOURCE_FILE_PATH_2: "apps/docs/pages/docs/discover"
TARGET_REPO_NAME: "developer-portal"
TARGET_REPO: "github.com/LedgerHQ/developer-portal"
TARGET_FILE_PATH_1: "pages/APIs/wallet-api"
TARGET_FILE_PATH_2: "pages/docs/discover"
TARGET_BRANCH: "main"
TARGET_PR_API_URL: "https://api.github.com/repos/LedgerHQ/developer-portal/pulls"
PR_TITLE: "Merging documentation from wallet-api"
PR_COMMIT_MESSAGE: "doc: add new changes from wallet-api doc"
PR_REVIEWERS: '{"reviewers": ["cfranceschi-ledger"]}'
PR_ASSIGN: '{"assignees": ["ramyeb"]}'
run: |
git clone --depth 1 https://${SOURCE_REPO}
git clone --depth 1 https://${DEVELOPER_PORTAL_CI_TOKEN}@${TARGET_REPO}
PR_BRANCH_NAME=sync-discover-doc-$(date +%s)
cd ${TARGET_REPO_NAME}
git checkout -b ${PR_BRANCH_NAME}
git remote set-url origin https://${DEVELOPER_PORTAL_CI_TOKEN}@${TARGET_REPO}
# Replace files
cp -rT ../${SOURCE_REPO_NAME}/${SOURCE_FILE_PATH_1} ${TARGET_FILE_PATH_1}
cp -rT ../${SOURCE_REPO_NAME}/${SOURCE_FILE_PATH_2} ${TARGET_FILE_PATH_2}
# Push changes
git add ${TARGET_FILE_PATH_1}
git add ${TARGET_FILE_PATH_2}
git commit -m "${PR_COMMIT_MESSAGE}"
git push origin ${PR_BRANCH_NAME}
git push https://${DEVELOPER_PORTAL_CI_TOKEN}@${TARGET_REPO} ${PR_BRANCH_NAME}
# Create Pull Request
PR_RESPONSE=$(curl -X POST -H "Authorization: token ${DEVELOPER_PORTAL_CI_TOKEN}" \
-d '{"title":"${PR_TITLE}","head":"'"$PR_BRANCH_NAME}"'","base":"${TARGET_BRANCH}"}' \
${TARGET_PR_API_URL})
PR_URL=$(echo $PR_RESPONSE | jq -r '.url')
PR_ISSUE_URL=$(echo $PR_RESPONSE | jq -r '.issue_url')
# Assign Reviewers
curl -s -X POST -H "Authorization: token ${DEVELOPER_PORTAL_CI_TOKEN}" \
-d "$PR_REVIEWERS" \
${PR_URL}/requested_reviewers
# Assign Users to the Pull Request
curl -s -X POST -H "Authorization: token ${DEVELOPER_PORTAL_CI_TOKEN}" \
-d "$PR_ASSIGN" \
${PR_ISSUE_URL}/assignees