Skip to content

Merge pull request #77 from rsksmart/devPortalTest #15

Merge pull request #77 from rsksmart/devPortalTest

Merge pull request #77 from rsksmart/devPortalTest #15

name: Update Devportal Documentation
on:
push:
paths:
- 'README.md'
branches:
- main
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-btc-transaction-solidity-helper-${TIMESTAMP}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
git clone https://github.com/rsksmart/devportal.git
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 lines from README.md
tail -n +3 README.md > temp_README.md
# Process README.md
echo "---" > transformed/README.md
echo "sidebar_label: Bitcoin Transaction Solidity Helper Library" >> transformed/README.md
echo "sidebar_position: 300" >> transformed/README.md
echo "title: How to Handle Bitcoin Transactions in Solidity" >> transformed/README.md
echo "description: 'This guide demonstrates to a developer how to handle Bitcoin transactions in a Solidity Smart contract, we will also learn how to parse transactions, hash transactions and validate scripts for bitcoin transactions.'" >> transformed/README.md
echo "tags: [rif, rootstock, solidity, bitcoin, smart contracts, libraries, bitcoin transactions]" >> 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 [Bitcoin Transaction Solidity Helper](https://github.com/rsksmart/btc-transaction-solidity-helper.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/08-libraries/bitcoin-tx-solidity-helper.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/08-libraries/bitcoin-tx-solidity-helper.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
TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S')
PR_TITLE="Btc-transaction-solidity-helper automated update of documentation - $TIMESTAMP"
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\":\"Btc-transaction-solidity-helper automated update of documentation ${TIMESTAMP}\",\"body\":\"This PR updates the Devportal documentation with the latest changes from the original repository.\",\"head\":\"${BRANCH_NAME}\",\"base\":\"main\"}"