Skip to content

Merge pull request #287 from rsksmart/testDevportalAutoImp #10

Merge pull request #287 from rsksmart/testDevportalAutoImp

Merge pull request #287 from rsksmart/testDevportalAutoImp #10

name: Update Devportal Documentation
on:
push:
paths:
- 'README.md'
branches:
- devportalAutoImplem
permissions: read-all
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Step 1: Clone the Devportal Repository
- name: Clone Devportal Repository
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
BRANCH_NAME="update-from-rif-relay-${TIMESTAMP}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
git clone https://github.com/rsksmart/devportal.git
cat devportal/docs/02-developers/06-integrate/01-rif-relay/integrate.md
cd devportal
git checkout -b ${BRANCH_NAME} || git checkout ${BRANCH_NAME}
cd ..
# Step 2: Transform Each File and Copy to Devportal Repository
- name: Transform Files for Devportal
run: |
mkdir -p transformed
# Remove the unwanted first lines from README.md
tail -n +1 README.md > temp_README.md
# Remove the lines between <!--START and <!--END-->
# awk '/<!--START/,/<!--END-->/{next} {print}' README.md > temp_README.md
# Process main README.md
echo "---" > transformed/README.md
echo "sidebar_label: Overview" >> transformed/README.md
echo "sidebar_position: 100" >> transformed/README.md
echo "title: RIF Relay - Overview" >> transformed/README.md
echo "description: 'RIF Relay Overview.'" >> transformed/README.md
echo "tags: [rif, envelope, relay, integrate, integration guide]" >> transformed/README.md
echo "---" >> transformed/README.md
echo "" >> transformed/README.md
echo ":::info[Note]" >> transformed/README.md
echo "If you wish to suggest changes on this document, please open a PR on the [Rif Relay Repository](https://github.com/rsksmart/rif-relay.git)" >> transformed/README.md
echo ":::" >> transformed/README.md
echo "" >> transformed/README.md
cat temp_README.md >> transformed/README.md
# Clean up temporary file
rm temp_README.md
cp transformed/README.md devportal/docs/02-developers/06-integrate/01-rif-relay/overview.md
# Process integrations section
# Remove the unwanted first lines from section (title)
tail -n +1 docs/integrate.md > temp_integrate.md
echo "---" > transformed/integrate.md
echo "sidebar_label: Integrations" >> transformed/integrate.md
echo "sidebar_position: 200" >> transformed/integrate.md
echo "title: RIF Relay Integration >> transformed/integrate.md
echo "description: 'Integrating RIF Relay in a dApp.'" >> transformed/integrate.md
echo "tags: [rif, envelope, relay, integration guide]" >> transformed/integrate.md
echo "---" >> transformed/integrate.md
echo "" >> transformed/integrate.md
cat temp_integrate.md >> transformed/integrate.md
# Clean up temporary file
rm temp_integrate.md
cp transformed/integrate.md devportal/docs/02-developers/06-integrate/01-rif-relay/integrate.md
cat devportal/docs/02-developers/06-integrate/01-rif-relay/integrate.md
# Process setup section
# Remove the unwanted first lines from section (title)
tail -n +1 docs/installation-requirements.md > temp_installation-requirements.md
echo "---" > transformed/installation-requirements.md
echo "sidebar_label: Setup" >> transformed/installation-requirements.md
echo "sidebar_position: 300" >> transformed/installation-requirements.md
echo "title: RIF Relay Installation Requirements >> transformed/installation-requirements.md
echo "description: 'Requirements for installing RIF Relay.'" >> transformed/installation-requirements.md
echo "tags: [rif, envelope, relay, user, guide]" >> transformed/installation-requirements.md
echo "---" >> transformed/installation-requirements.md
echo "" >> transformed/installation-requirements.md
cat temp_installation-requirements.md >> transformed/installation-requirements.md
# Clean up temporary file
rm temp_installation-requirements.md
cp transformed/installation-requirements.md devportal/docs/02-developers/06-integrate/01-rif-relay/installation-requirements.md
# Step 3: Commit and Push Changes to Devportal Repository
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
cd devportal
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/02-developers/06-integrate/01-rif-relay/overview.md docs/02-developers/06-integrate/01-rif-relay/integrate.md
git diff --cached
# git add docs/02-developers/06-integrate/01-rif-relay/overview.md docs/02-developers/06-integrate/01-rif-relay/integrate.md docs/02-developers/06-integrate/01-rif-relay/installation-requirements.md docs/02-developers/06-integrate/01-rif-relay/sample-dapp.md docs/02-developers/06-integrate/01-rif-relay/deployment.md docs/02-developers/06-integrate/01-rif-relay/develop.md docs/02-developers/06-integrate/01-rif-relay/contracts.md docs/02-developers/06-integrate/01-rif-relay/smart-wallets.md docs/02-developers/06-integrate/01-rif-relay/versions.md docs/02-developers/06-integrate/01-rif-relay/gas-costs.md docs/02-developers/06-integrate/01-rif-relay/architecture.md
git commit -m "Automated update from repository"
# Configure the remote URL with the token for authentication
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/rsksmart/devportal.git
git push -f origin ${BRANCH_NAME}
# Step 4: Create a Pull Request in the Devportal Repository
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
cd devportal
curl -L -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/rsksmart/devportal/pulls \
-d "{\"title\":\"Rif-relay automated update of documentation ${BRANCH_NAME}\",\"body\":\"This PR updates the Devportal documentation with the latest changes from the original repository.\",\"head\":\"${BRANCH_NAME}\",\"base\":\"main\"}"