Folder has several text files and I want to merge them to Merge.txt
when adding new files or editing files. Nothing advanced only copy the text and commit.
This should be super easy, but I can’t find anyone who has a solution.
# This is a basic workflow to help you get started with Actions
name: CI
Controls when the workflow will run
on:
Triggers the workflow on push or pull request events but only for the "main" branch
push: branches: [ "main" ]
pull_request: branches: [ "main" ]
Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
This workflow contains a single job called "build"
build: # The type of runner that the job will run on runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell
- name: Merge TXT Files
run: |
find . -type f -name '*.txt' | while read fname; do
2
Answers
You can use something like this to merge multiple
.txt
files to a singleMerge.txt
file, if you want to commit that Merge.txt file then you can use other existing actions. I am going to show only the file merging example.Output: