GitHub Action for copying one markdown file and paste it to another markdown file's specific location.
-
This is a GitHub Action to copy one markdown file data and paste it to another markdown file's specific location.
-
This action runs in a Docker container and therefore only supports Linux.
- You need to update the markdown file(.md) with 2 comments. You can refer here for updating it.
- You'll need a GitHub API Token with
repo
anduser
scope from here if you're running the action.enabling the
repo
scope seems DANGEROUS
but this GitHub Action only accesses your repository information and use the api to update the markdown file- You can use this example to work it out
- You need to save the GitHub API Token in the repository secrets. You can find that in the Settings of your repository. Be sure to save those as the following.Reffer here for more info
- GitHub Personal Access Token as
TOKEN=<your github access token>
- GitHub Personal Access Token as
The following example workflow step will copy the data of the markdown file from specified location inside the repository running the action, to any markdown file with specified location index(by default README.md). If the data already exist at the destination Markdown File, It will not update anything.
name: Test Workflow
on:
push:
branches:
- main
workflow_dispatch:
jobs:
Update-Readme:
runs-on: ubuntu-latest
steps:
- name: Copy Paste Action
uses: ShreyamMaity/Copy-Paste-Action@main
with:
TOKEN: ${{ secrets.TOKEN }}
REPOSITORY : 'Your Repository Name'
COPY-FILE-LOCATION : './database/db.md'
PASTE-FILE-LOCATION : './README.md'
Add a comment to your markdown file
or README.md
like this:
<!--START_SECTION:cp-->
<!--END_SECTION:cp-->
These lines will be our entry-points for the copy paste action.
token
: (required) GitHub Private Access Token used for the clone/push operations. To create it follow the GitHub Documentation.
The following input variable options can/must be configured:
Input variable | Necessity | Description |
---|---|---|
TOKEN |
Required | Your Github Token |
REPOSITORY |
Required | Name of your repository where you are running this github action |
COPY-FILE-LOCATION |
Required | The Specific Location of the markdown file from where you want to copy the data.For example ./file.md or ./folder/file.md |
PASTE-FILE-LOCATION |
Required | The Specific Location of the markdown file from where you want to paste the data of copied markdown file.For example ./README.md or ./folder/file.md |
- Open this repository
- This repository has a database.md fie inside Database folder
- This github action copies the information from database.md file and paste it to README.md file of the Repository
The Copy Paste GitHub action is written by Shreyam Maity
This project is licensed under the MIT License - see the LICENSE file for details.