Git Product home page Git Product logo

add-and-commit's Issues

Ts-only not working

##[error]Error: warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

It seems like EndBug/add-and-commit@ts-only does not work yet.

Originally posted by @bmartinez287 in #53 (comment)

Specify branch name

On scheduled workflow it is not possible to run add-and-commit against a specific branch since it relies on ${GITHUB_REF}.

schedule always use the last commit on default branch.

on:
  schedule:
    - cron: "50 10,17,20,23 * * *"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: gh-pages # a custom branch

    - name: Commit changes
      uses: EndBug/add-and-commit@v4
      with:
        message: "Updated file"
        add: "file.csv"
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I tried passing GITHUB_REF: refs/heads/gh-pages in env, but it didn't work

Default secret name is invalid

GitHub wont allow a Secret named GITHUB_TOKEN, it complains Failed to add secret. Name is invalid.

Then the action complains:

/Users/runner/work/_actions/EndBug/add-and-commit/v4/lib/entrypoint.sh: line 11: GITHUB_TOKEN: unbound variable

Pushing commits to repo...
  fatal: could not read Username for 'https://github.com': Device not configured
Pushing tags to repo...
  fatal: could not read Username for 'https://github.com': Device not configured

And it wont commit nor push.
Would be nice to change the default Secret name.

Question: pull from main - push to otherbranch?

Use case:
I have a front-end (Angular/React) and a backend repository. When the CI is building the front-end, the result of the build folder needs to be committed to the /static directory of the backend repo. With your contribution I came close - love it.
The last hurdle is the error:

** Error: warning: Pulling without specifying how to reconcile divergent branches is discouraged **

which AFAIK stems from the fact that I checkout master from backend and try to push to (the non-existing) branch ui-contribution. Is there a way I can push to a new (or eventually existing) branch. -u --force might do the trick, but where to put in in the YAML. My stuff so far:

name: Reconcile front and backend

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  buildui:
    name: Building UI
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Backend
        uses: actions/checkout@v2
        with:
          repository: acme/backend
          token: ${{secrets.UI_PUSH_TOKEN }}
          ref: main
          path: backend
      - name: Checkout UI
        uses: actions/checkout@v2
      - name: Deploy NodeJS
        uses: actions/setup-node@v1
        with:
          node-version: "12.x"
      - run: npm install
      - run: npm run build --if present
      - run: npm test
      - name: Send them back
        uses: EndBug/add-and-commit@v5
        with:
          cwd: "./backend"
          branch: "ui-commit"
          message: "[Auto-commit] from UI"
        env:
          GITHUB_TOKEN: ${{secrets.UI_PUSH_TOKEN }}

Love your work!

TypeError: Object prototype may only be an Object or null: undefined

Getting the below error when using the newest version v5.1.1
This has worked up until recently and rolling back to v5.1.0 works great.
So far, going through the code I haven't been able to find the issue.

Run EndBug/add-and-commit@v5
Running in /home/runner/work/<repo>
> Unable to get commit from workflow event: trying with the GitHub API...
> Using 'Devops Bot <email>' as author.
> Using "Updating members.csv" as commit message.
Internal logs
Error: TypeError: Object prototype may only be an Object or null: undefined

Force push

This is not a bug report but a simple question.
Is it possible to tell the action to force push?

Changes Not Committed Due to Lack of Write Access

You can check out this pull request (TheRenegadeCoder/sample-programs-website#375), but basically I generate images during pull requests. It works fine when I make the pull request, but it doesn't seem to be working for someone else. I gave them write access, but it still won't commit. I suspect it has something to do with the fact that they're on a fork, but again... I don't really know what's happening.

Here's the workflow file:

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  pull_request:
    branches:
      - master

# 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@v2
      - uses: actions/setup-python@v2
        with:
          python-version: '3.8'

      # Runs a single command using the runners shell
      - name: Install Image Titler
        run: pip install image-titler

      # Runs a set of commands using the runners shell
      - name: Generate Images
        run: |
          sources=assets/sources/
          images=assets/images/
          logo=icon-small.png
          for file in "$sources"*
          do
            image-titler --path "$file" --output "$images" --logo "$images$logo"
            filename=$(basename "$file")
            edit=$(cd "$images" && ls -t | head -n1)
            mv "$images$edit" "$images$filename" 
          done
      
      - name: Commit Changes
        uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
        with:
          # The message for the commit
          # Default: 'Commit from GitHub Actions'
          message: 'Generated featured images from sources'

        env:
          # This is necessary in order to push a commit to the repo
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged

I recently changed it to commit as me through the author name and email options, but I'm not sure if that will change anything. Ultimately, here's the log:

2020-10-24T18:05:58.1644820Z ##[group]Run EndBug/add-and-commit@v5
2020-10-24T18:05:58.1645104Z with:
2020-10-24T18:05:58.1645382Z   message: Generated featured images from sources
2020-10-24T18:05:58.1645652Z   add: .
2020-10-24T18:05:58.1645818Z   cwd: .
2020-10-24T18:05:58.1645965Z env:
2020-10-24T18:05:58.1646275Z   pythonLocation: /opt/hostedtoolcache/Python/3.8.6/x64
2020-10-24T18:05:58.1646709Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.6/x64/lib
2020-10-24T18:05:58.1648545Z   GITHUB_TOKEN: ***
2020-10-24T18:05:58.1648797Z ##[endgroup]
2020-10-24T18:05:58.2126836Z Running in /home/runner/work/sample-programs-website/sample-programs-website
2020-10-24T18:05:58.2136841Z > Unable to get commit from workflow event: trying with the GitHub API...
2020-10-24T18:05:58.4029890Z > Using 'Stuart Irwin <[email protected]>' as author.
2020-10-24T18:05:58.4030529Z > Using "Generated featured images from sources" as commit message.
2020-10-24T18:05:58.4031219Z > Running for a PR, the action will use 'master' as ref.
2020-10-24T18:05:58.4035676Z ##[group]Internal logs
2020-10-24T18:05:58.4037460Z > Staging files...
2020-10-24T18:05:58.4039492Z > Adding files...
2020-10-24T18:05:59.0066683Z > No files to remove.
2020-10-24T18:05:59.0067187Z > Checking for uncommitted changes in the git working tree...
2020-10-24T18:05:59.0124287Z > Found 9 changed files.
2020-10-24T18:05:59.4908043Z FetchSummary {
2020-10-24T18:05:59.4909472Z   raw: 'From https://github.com/TheRenegadeCoder/sample-programs-website\n' +
2020-10-24T18:05:59.4910353Z     ' * [new branch]      master     -> origin/master\n',
2020-10-24T18:05:59.4911220Z   remote: 'https://github.com/TheRenegadeCoder/sample-programs-website',
2020-10-24T18:05:59.4912159Z   branches: [ { name: 'master', tracking: 'origin/master' } ],
2020-10-24T18:05:59.4912523Z   tags: []
2020-10-24T18:05:59.4912720Z }
2020-10-24T18:05:59.4913019Z > Switching/creating branch...
2020-10-24T18:05:59.5033444Z A	assets/images/baklava-in-c.jpg
2020-10-24T18:05:59.5034711Z A	assets/images/baklava-in-kotlin.jpg
2020-10-24T18:05:59.5035610Z A	assets/images/file-io-in-every-language.jpg
2020-10-24T18:05:59.5036485Z A	assets/images/fizz-buzz-in-befunge.jpg
2020-10-24T18:05:59.5037264Z A	assets/images/fizz-buzz-in-java.jpg
2020-10-24T18:05:59.5038012Z A	assets/images/fizz-buzz-in-lisp.jpg
2020-10-24T18:05:59.5038813Z A	assets/images/reverse-a-string-in-c.jpg
2020-10-24T18:05:59.5039825Z A	assets/images/reverse-a-string-in-every-language.jpg
2020-10-24T18:05:59.5040885Z A	assets/images/reverse-a-string-in-python.jpg
2020-10-24T18:05:59.5041792Z Branch 'master' set up to track remote branch 'master' from 'origin'.
2020-10-24T18:05:59.5042189Z 
2020-10-24T18:05:59.5042570Z > Pulling from remote...
2020-10-24T18:05:59.6287177Z FetchSummary { raw: '', remote: null, branches: [], tags: [] }
2020-10-24T18:05:59.7638843Z PullSummary {
2020-10-24T18:05:59.7639670Z   remoteMessages: RemoteMessageSummary { all: [] },
2020-10-24T18:05:59.7640204Z   created: [],
2020-10-24T18:05:59.7640542Z   deleted: [],
2020-10-24T18:05:59.7640848Z   files: [],
2020-10-24T18:05:59.7641216Z   deletions: {},
2020-10-24T18:05:59.7641572Z   insertions: {},
2020-10-24T18:05:59.7642011Z   summary: { changes: 0, deletions: 0, insertions: 0 }
2020-10-24T18:05:59.7642409Z }
2020-10-24T18:05:59.7643217Z > Re-staging files...
2020-10-24T18:05:59.7708578Z > Creating commit...
2020-10-24T18:05:59.7799416Z CommitSummary {
2020-10-24T18:05:59.7800345Z   branch: 'master',
2020-10-24T18:05:59.7801024Z   commit: 'a5dfd6c',
2020-10-24T18:05:59.7801818Z   summary: { changes: 9, insertions: 0, deletions: 0 },
2020-10-24T18:05:59.7802387Z   author: null
2020-10-24T18:05:59.7802821Z }
2020-10-24T18:05:59.7803536Z > No tag info provided.
2020-10-24T18:05:59.7804075Z > Pushing commit to repo...
2020-10-24T18:05:59.9026378Z ##[error]Error: Pushing to https://github.com/TheRenegadeCoder/sample-programs-website
remote: Permission to TheRenegadeCoder/sample-programs-website.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/TheRenegadeCoder/sample-programs-website/': The requested URL returned error: 403

2020-10-24T18:05:59.9038586Z ##[endgroup]
2020-10-24T18:05:59.9049301Z ##[error]Error: Pushing to https://github.com/TheRenegadeCoder/sample-programs-website
remote: Permission to TheRenegadeCoder/sample-programs-website.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/TheRenegadeCoder/sample-programs-website/': The requested URL returned error: 403

v2.3.3 appears to be broken

Hi,

The latest update, v2.3.3, appears to have broken the action from the previous version as I am now seeing this in my workflow log instead of changes being committed:

Switching branch...
Switched to branch 'master'
M	addon/install.rdf
M	updates.json
Pulling from remote...
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Also, it does not cause the workflow step to error either so the workflow appears to have completed successfully even though the changes were not applied back to the remote/master

Pinning to v2.3.2 has the step working perfectly fine once again (and has stopped me pulling my hair out thinking it was something I'd done seeing as I'm new to github workflows ;-p )

Error: could not read Username for 'https://github.com': No such device or address

I get an error trying to use this

Run EndBug/add-and-commit@v5
  with:
    message: [ESLint] Auto formatting.
    add: *.js
    cwd: .
  env:
    GITHUB_TOKEN: ***
Running in /home/runner/work/actions-test/actions-test
> Using 'WilsontheWolf <[email protected]>' as author.
> Using "[ESLint] Auto formatting." as commit message.
Internal logs
  > Staging files...
  > Adding files...
  > No files to remove.
  > Checking for uncommitted changes in the git working tree...
  > Found 1 changed files.
  FetchSummary { raw: '', remote: null, branches: [], tags: [] }
  > Switching/creating branch...
  M	index.js
  Branch 'master' set up to track remote branch 'master' from 'origin'.
  
  > Pulling from remote...
  FetchSummary { raw: '', remote: null, branches: [], tags: [] }
  PullSummary {
    remoteMessages: RemoteMessageSummary { all: [] },
    created: [],
    deleted: [],
    files: [],
    deletions: {},
    insertions: {},
    summary: { changes: 0, deletions: 0, insertions: 0 }
  }
  > Re-staging files...
  > Creating commit...
  CommitSummary {
    branch: 'master',
    commit: '84f00c4',
    summary: { changes: 1, insertions: 3, deletions: 3 },
    author: null
  }
  > No tag info provided.
  > Pushing commit to repo...
  Error: Error: Pushing to https://github.com/WilsontheWolf/actions-test
  fatal: could not read Username for 'https://github.com': No such device or address
  
Error: Error: Pushing to https://github.com/WilsontheWolf/actions-test
fatal: could not read Username for 'https://github.com': No such device or address

file
I'm not sure what I'm doing wrong.

From docker to node

Hi

My fork of your repository is rewritten as a node-artifact and do not need any Dockerfile. However, my GitHub workflow fails when using the node-branch (I also tried the master branch with docker). The failure is caused by the folder node_modules being ignored: https://github.com/jactor-rises/add-and-commit/runs/345587672

Is this a suspected failure and has something todo with the default pattern?

Action doesn't support PRs

- name: Commit new expectations
      if: failure() && github.actor != 'patrickhulce' && github.actor != 'brendankenny'
      uses: EndBug/add-and-commit@v4
      with:
        cwd: ${{ github.workspace }}/lighthouse
        add: lighthouse-core/scripts/chromium-web-tests/webtests
        message: update webtest expectations
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

results

2020-07-30T17:18:06.7641560Z ##[group]Run EndBug/add-and-commit@v4
2020-07-30T17:18:06.7641780Z with:
2020-07-30T17:18:06.7641920Z   cwd: /Users/runner/work/lighthouse/lighthouse/lighthouse
2020-07-30T17:18:06.7642060Z   add: lighthouse-core/scripts/chromium-web-tests/webtests
2020-07-30T17:18:06.7642190Z   message: update webtest expectations
2020-07-30T17:18:06.7642310Z   force: false
2020-07-30T17:18:06.7642430Z   signoff: false
2020-07-30T17:18:06.7642520Z env:
2020-07-30T17:18:06.7643020Z   DEPOT_TOOLS_PATH: /Users/runner/work/lighthouse/lighthouse/depot-tools
2020-07-30T17:18:06.7643180Z   DEVTOOLS_PATH: /Users/runner/work/lighthouse/lighthouse/devtools-frontend
2020-07-30T17:18:06.7643320Z   BLINK_TOOLS_PATH: /Users/runner/work/lighthouse/lighthouse/blink_tools
2020-07-30T17:18:06.7643660Z   PATH: /Users/runner/work/lighthouse/lighthouse/depot-tools:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.6.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.3.1/x64
2020-07-30T17:18:06.7645500Z   GITHUB_TOKEN: ***
2020-07-30T17:18:06.7645680Z ##[endgroup]
2020-07-30T17:18:06.8307770Z ##[warning]Unable to fetch author info: couldn't find commit.
2020-07-30T17:18:06.8310040Z Using 'Add & Commit Action <[email protected]>' as author.
2020-07-30T17:18:07.0264680Z ##[group]Internal logs
2020-07-30T17:18:07.0266530Z Running in /Users/runner/work/lighthouse/lighthouse/lighthouse.
2020-07-30T17:18:07.0267290Z Staging files...
2020-07-30T17:18:07.0818220Z Checking for uncommitted changes in the git working tree...
2020-07-30T17:18:13.0685140Z From https://github.com/GoogleChrome/lighthouse
2020-07-30T17:18:13.0703980Z  * [new branch]      520viewer               -> origin/520viewer
2020-07-30T17:18:13.0723380Z  * [new branch]      78a1a8f                 -> origin/78a1a8f
... snip ...
2020-07-30T17:18:13.9081000Z Creating branch...
2020-07-30T17:18:13.9081220Z Switching branch...
2020-07-30T17:18:13.9082160Z M	lighthouse-core/scripts/chromium-web-tests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt
2020-07-30T17:18:13.9082410Z Pulling from remote...
2020-07-30T17:18:13.9082610Z Resetting files...
2020-07-30T17:18:13.9082830Z Unstaged changes after reset:
2020-07-30T17:18:13.9084080Z M	lighthouse-core/scripts/chromium-web-tests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt
2020-07-30T17:18:13.9084310Z Adding files...
2020-07-30T17:18:13.9084500Z Removing files...
2020-07-30T17:18:13.9084660Z Creating commit...
2020-07-30T17:18:13.9084920Z [1176/merge eb1d6c829] update webtest expectations
2020-07-30T17:18:13.9085880Z  1 file changed, 2 insertions(+), 2 deletions(-)
2020-07-30T17:18:13.9086140Z Tagging commit...
2020-07-30T17:18:13.9086360Z Pushing commits to repo...
... snip ...
2020-07-30T17:18:13.9211750Z Switched to branch '1176/merge'
2020-07-30T17:18:13.9212410Z warning: Pulling without specifying how to reconcile divergent branches is
2020-07-30T17:18:13.9212810Z discouraged. You can squelch this message by running one of the following
2020-07-30T17:18:13.9213080Z commands sometime before your next pull:
2020-07-30T17:18:13.9213160Z 
2020-07-30T17:18:13.9213380Z   git config pull.rebase false  # merge (the default strategy)
2020-07-30T17:18:13.9213570Z   git config pull.rebase true   # rebase
2020-07-30T17:18:13.9214200Z   git config pull.ff only       # fast-forward only
2020-07-30T17:18:13.9214290Z 
2020-07-30T17:18:13.9214960Z You can replace "git config" with "git config --global" to set a default
2020-07-30T17:18:13.9215670Z preference for all repositories. You can also pass --rebase, --no-rebase,
2020-07-30T17:18:13.9216380Z or --ff-only on the command line to override the configured default per
2020-07-30T17:18:13.9216630Z invocation.
2020-07-30T17:18:13.9216750Z 
2020-07-30T17:18:13.9216960Z There is no tracking information for the current branch.
2020-07-30T17:18:13.9217240Z Please specify which branch you want to merge with.
2020-07-30T17:18:13.9217830Z See git-pull(1) for details.
2020-07-30T17:18:13.9217970Z 
2020-07-30T17:18:13.9218150Z     git pull <remote> <branch>
2020-07-30T17:18:13.9218220Z 
2020-07-30T17:18:13.9218500Z If you wish to set tracking information for this branch you can do so with:
2020-07-30T17:18:13.9218630Z 
2020-07-30T17:18:13.9219170Z     git branch --set-upstream-to=origin/<branch> 1176/merge
2020-07-30T17:18:13.9219330Z 
2020-07-30T17:18:17.3261630Z remote: 
2020-07-30T17:18:17.3263040Z remote: Create a pull request for '1176/merge' on GitHub by visiting:        
2020-07-30T17:18:17.3263530Z remote:      https://github.com/GoogleChrome/lighthouse/pull/new/1176/merge        
2020-07-30T17:18:17.3263770Z remote: 
2020-07-30T17:18:17.3293910Z To https://github.com/GoogleChrome/lighthouse
2020-07-30T17:18:17.3294840Z  * [new branch]          1176/merge -> 1176/merge
2020-07-30T17:18:17.3367900Z Branch '1176/merge' set up to track remote branch '1176/merge' from 'origin'.
2020-07-30T17:18:17.3371130Z Pushing tags to repo...
2020-07-30T17:18:17.6857510Z Everything up-to-date
2020-07-30T17:18:17.6881390Z Branch '1176/merge' set up to track remote branch '1176/merge' from 'origin'.

ref https://github.com/GoogleChrome/lighthouse/runs/928694099?check_suite_focus=true#step:20:332

It seems that GITHUB_REF is set to 1176/merge, a branch that GitHub made which merges master into the PR branch before running the tests. If GitHub does that, how can this action commit to the PR branch directly?

Create a Pull Request

Hi, I love this action, but I can't use it on one of my repos, because the master branch there is protected. As it's protected for good reasons but I'd still like to automate some of the repo content, I thought whether I could add-and-commit-and-send-pr. Would something like this be a responsibility of this action or it's out of the scope of the project and I should look at other actions?

refusing to allow a GitHub App to create or update workflow `.github/workflows/rating-chart.yml` without `workflows` permission

Thanks for the repo. I am using this to add and commit my README.md using workflows ... I am able to successfully commit and push README.md however, I am not able to push workflows YAML file which fails with a permission issue, even though commit and add works fine here. The issue is :

! [remote rejected] master -> master (refusing to allow a GitHub App to create or update workflow .github/workflows/rating-chart.yml without workflows permission)

I have tried adding a secret environment variable of a new token with workflow scope as well. There seems to be no improvement (I am guessing workflow scope in a token vs workflow permission are two separate things, but I may be wrong)

Can you let me know how this can be resolved.
Here is my repo - https://github.com/sciencepal/sciencepal
Here is a sample workflow (Check internal logs of add-and-commit job step) - https://github.com/sciencepal/sciencepal/runs/984418665

Commit all changed files?

As I understand the code below, using pattern: "*" will try to add files from .git repository

else find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $x; done

Add the possibility NOT to push

Hi,

thanks for this action, pretty handy.
I just have a little request : I have a use case where I run a series of tasks and on every step I would like to commit the changed/new files, but I only would like to push at the very end of the process. So in my case it would make sense to have an option to skip the git push on specific tasks.
What do you think?

Run the action from a different directory

Hi,

I am trying to use this Github Actions to push a VuePress website from a source branch to a master branch.
The website is generated using a regular npm run build script and the build outputs to ./docs/.vuepress/dist.

./ here is the root of my repo.

I would like to only push files inside of this directory to the master, not the whole path.

The problem is that currently the action is running git add from the root folder, instead of running it from .docs/.vuepress/dist... resulting in having the full path pushed to the master branch.

As for now Github Actions working-directory can't be used in addition with the uses command, it would be nice to have a directory option to tell the action where to run the git add command.

Here is my worflow:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      (...)
      - name: Commit changes
        uses: EndBug/add-and-commit@master
        with:
          branch: "master"
          add: "docs/.vuepress/dist --force"
          message: "Deploy docs"

Here is a workflow we could have:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      (...)
      - name: Commit changes
        uses: EndBug/add-and-commit@master
        with:
          branch: "master"
          directory: "docs/.vuepress/dist" <--- the action will run "cd [directory]" command before running
          add: ". --force"
          message: "Deploy docs"

You can have a look at the current VuePress deploy script here:
https://vuepress.vuejs.org/guide/deploy.html#github-pages

Thanks for your feedback! ๐Ÿ˜‰

[Request] Add option to delete files

I know that it can be cleared using command like this - run: git rm delete_me.txt.
But syntax of this action is not full human understandable and need to know git commands.

Request is to add clear option. I think this simple action can close many issues and cases when needed to fully recreate destination folder/repository. And make code more simple and clear.

This is not functionality issue, but syntax and clean code.

PS: And documentation after that will be more simple too. No need big example of how to clean. Just one new option.

Not sure how to use add-and-commit to push changes from master to gh-pages

Hi,

I am trying to:

  1. Run jsdoc on my src files located in the master branch to generate HTML documentation in a top-level api-docs/ directory.
  2. Commit these changes to the gh-pages branch (so that I can see them in a browser).

My workflow is here:

https://github.com/radgrad/radgrad2/actions/runs/338143921/workflow

But when it runs, it doesn't see any changes so nothing is committed:

https://github.com/radgrad/radgrad2/runs/1333440463?check_suite_focus=true

I know I am missing something simple here, probably with git, but perhaps with your package. Could you advise me on what to do differently?

Thanks!

Can't push to protected branch

May not be a bug but I can't figure it out. How do I grant access to action runner to be able to push to protected branch?
What's interesting is that error indicates it's pull request which it is not.
Describe the bug
So if branch has any of given protections:

  • Require pull request reviews before merging
  • Status checks found in the last week for this repository
    it fails to push the changes.

Workflow used

        run: ./docker.sh vendor/bin/php-cs-fixer fix
      - name: Commit fixes
        uses: EndBug/add-and-commit@v5
        with:
          author_name: Github Actions
          author_email: [email protected]
          message: '[auto] php-cs-fixer'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expected behavior
To push the changes

Logs

Pushing commit to repo...
Error: Error: Pushing to XXXX
POST git-receive-pack (683 bytes)
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: At least 1 approving review is required by reviewers with write access.
error: failed to push some refs to XXXX

v5 is not released

Example from README

- uses: EndBug/add-and-commit@v5

But on github actions

image

Ability to trigger "on push" actions

I have a separate workflow that normally runs any time a change is pushed to the repo. It looks like this:

on:
  push:
    branches:
      - master
    paths:
      - "**"

I expected changes committed by EndBug/add-and-commit@v4 to trigger the same behavior, but they do not.

fatal: invalid refspec '/merge'

When running this on a pull-request I get the following error.

fatal: invalid refspec '/merge'

Another issue is that even if it fails it reports as successful.

Can't find commit when triggering on release publish

When working on a pipeline that is triggered by a release publish:

on:
  release:
    types: [ published ]

I get the following error:

Unable to get commit from workflow event: trying with the GitHub API...
Error: Request failed with status code 404
    at createError (/home/runner/work/_actions/EndBug/add-and-commit/v4.4.0/lib/index.js:1:428)
    at settle (/home/runner/work/_actions/EndBug/add-and-commit/v4.4.0/lib/index.js:1:31578)

It seems like the latest changes have broken this functionality. I pinned the library to v4.3.0 and was able to run successfully.

Receive spawn UNKNOWN in windows-latest

Error

Error: spawn UNKNOWN
at ChildProcess.spawn (internal/child_process.js:394:11)
at spawn (child_process.js:540:9)
at Object.execFile (child_process.js:224:17)
at Object.131 (D:\a_actions\EndBug\add-and-commit\v4\lib\index.js:1:592)
at webpack_require (D:\a_actions\EndBug\add-and-commit\v4\lib\index.js:1:154)
at startup (D:\a_actions\EndBug\add-and-commit\v4\lib\index.js:1:291)
at module.exports.87 (D:\a_actions\EndBug\add-and-commit\v4\lib\index.js:1:323)
at Object. (D:\a_actions\EndBug\add-and-commit\v4\lib\index.js:1:333)
##[error]spawn UNKNOWN
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) {
errno: 'UNKNOWN',
code: 'UNKNOWN',
syscall: 'spawn'

The following system:

Operating System
Microsoft Windows Server 2019
10.0.17763
Datacenter
Virtual Environment
Environment: windows-2019
Version: 20200630.0

It is not possible to push a tag without changing files

If no files in the repository has been changed or touched, the action will do nothing, even when the tag option is used.

My use case for this is I have a workflow which merges from a staging branch to a production branch, a build to some third party (without changing any local files), and should add a tag which indicates that this commit is what was sent to the third party.

Thank you!

Avoid workflow get launched after commit in a loop !

Describe the bug
I am using EndBug/add-and-commit@v5 but it launches a loop of Github Actions because, everytime there is a change the workflow get launched.

There is no support for that, and it looks like every body is gonna have the same issue.

Workflow used

name: Workflow branch master
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    name: Build and push image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.REPO_TOKEN }}
      - name: Upgrade the version
        run: |
          VERSION=$(grep -oP '(?<=latest-)[0-9]+' ./.github/workflows/build-and-push-image-to-registry.yaml)
          OLD_VERSION=$VERSION
          NEW_VERSION=$(($VERSION + 1))
          sed -i "s/latest-$OLD_VERSION/latest-$NEW_VERSION/g" ./scaleway/values.yaml
          sed -i "s/latest-$OLD_VERSION/latest-$NEW_VERSION/g" ./.github/workflows/build-and-push-image-to-registry.yaml
      - name: Commit changes
        uses: EndBug/add-and-commit@v5
        with:
          message: "Robot version upgrade"
          add: "."
        env:
          GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}

Expected behavior
I wanna launch this workflow only if commit message is Robot version upgrade

Support collections as values for `add`, `rm` and so on

Hello, I think it would improve usability if we could use multiple git add commands with within a single action. For example:

- name: Commit changes
      uses: EndBug/add-and-commit@v5
      with:
        author_name: Your Name
        author_email: [email protected]
        message: "Your commit message"
        add:
            - "something/file.txt"
            - "crazy/*"
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This wouldn't even be a breaking change if both collections and scalars are supported.

At the moment it is possible to to it like this git add file-1 file-2 file-3, which translates to add: file-1 file-2 file-3, but what if the path has a space in it?

Changes are not committed

In version 4, the local changes were committed, but in v5 it is not committed and it tries to pull with the dirty local directory. The changes from the previous configuration were the version and I specified branch instead of ref. Any idea what could be my issue?

This is the workflow:

---
name: Test
on: push
jobs:
  build-linux:
    runs-on: runner
    name: Test
    steps:
      - name: Fetch
        uses: actions/checkout@v2
        with:
          path: netrc
          ref: netrc
      - name: modify
        run: echo test >> netrc/tokens
      - name: Commit changes
        uses: EndBug/add-and-commit@v5
        with:
          branch: "netrc"
          cwd: "netrc"
          author_name: <my name>
          author_email: <my email>
          message: "Save"
          add: "tokens"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

and here is the internal log:

  > Staging files...
  > Adding files...
  > No files to remove.
  > Checking for uncommitted changes in the git working tree...
  > Found 1 changed files.
  FetchSummary {
    raw: 'From https://github.com/sot/test-actions\n' +
      '   16d867b..daa2b2b  master     -> origin/master\n',
    remote: 'https://github.com/sot/test-actions',
    branches: [],
    tags: []
  }
  > Switching/creating branch...
  M	tokens
  Your branch is up to date with 'origin/netrc'.
  
  > Pulling from remote...
  FetchSummary { raw: '', remote: null, branches: [], tags: [] }
  Error: Error: error: cannot pull with rebase: Your index contains uncommitted changes.
  error: please commit or stash them.

Failure to push isn't considered an error.

In case pushing changes fails (most likely due to incorrect permissions) the action and workflow is considered successful.
I expected it to cause a failure.

  Tagging commit...
  Pushing commits to repo...
  remote: Permission to karliss/github-integration-test.git denied to github-actions[bot].
  fatal: unable to access 'https://github.com/karliss/github-integration-test/': The requested URL returned error: 403
  Pushing tags to repo...
  remote: Permission to karliss/github-integration-test.git denied to github-actions[bot].
  fatal: unable to access 'https://github.com/karliss/github-integration-test/': The requested URL returned error: 403

Change how Github token is retrieved

It works fine for me without the token: https://github.com/Cyberbeni/ShowTouches/runs/1579363839?check_suite_focus=true#step:5:63

There is also this similar action that gets GITHUB_TOKEN like this: https://github.com/peter-evans/create-pull-request/blob/master/action.yml#L4-L6

Edit: it works without the token because I checked out the repo before and that also got the token the same way as the other action: https://github.com/actions/checkout/blob/main/action.yml#L12-L24

ENOBUFS error when the to be committed files exceed 1MB

I am trying to commit the docs folder generated in a previous step. This throws the following error after 1s on execFileSync. I found that ENOBUFS is thrown when the maxBuffer (1MB by default) gets exceeded.

This happens to be the case here. When only committing a single HTML file from the docs folder, the action succeeds as expected.

Possible solution
The buffer size can be specified as an option with execFileSync. More in the docs of Node.js. Setting an increased maxBuffer might solve the issue.

Run EndBug/add-and-commit@v4
  with:
    add: docs
    author_name: Github Workflow Bot
    author_email: [email protected]
    message: build docs and dist
    cwd: .
    force: false
  env:
    GITHUB_TOKEN: ***
Using 'Github Workflow Bot <[email protected]>' as author.
Error: spawnSync /home/runner/work/_actions/EndBug/add-and-commit/v4/lib/entrypoint.sh ENOBUFS
    at Object.spawnSync (internal/child_process.js:1041:20)
    at spawnSync (child_process.js:607:24)
    at Object.execFileSync (child_process.js:634:15)
    at Object.131 (/home/runner/work/_actions/EndBug/add-and-commit/v4/lib/index.js:1:576)
    at __webpack_require__ (/home/runner/work/_actions/EndBug/add-and-commit/v4/lib/index.js:1:154)
    at startup (/home/runner/work/_actions/EndBug/add-and-commit/v4/lib/index.js:1:291)
    at module.exports.87 (/home/runner/work/_actions/EndBug/add-and-commit/v4/lib/index.js:1:323)
    at Object.<anonymous> (/home/runner/work/_actions/EndBug/add-and-commit/v4/lib/index.js:1:333)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)

My workflow yml:

name: Build and release

on:
  push:
    # branches:
    #   - master
    paths-ignore:
      - 'docs/**'

jobs:
  node:
    name: Node 12
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Sync packages with cache
        uses: actions/cache@v1
        with:
          path: ./node_modules
          key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
          restore-keys: ${{ runner.os }}-node_modules-

      - name: Install packages
        run: yarn install --frozen-lockfile

      - name: Build the docs
        run: yarn document

      - name: Commit docs
        uses: EndBug/add-and-commit@v4
        with:
          add: 'docs'
          author_name: Github Workflow Bot
          author_email: [email protected]
          message: 'build docs'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Action creates a .netrc file in home directory

In my setup, I am using a runner on premises. This runner does a couple other things. I included this action on a workflow I sent to that runner, and a side effect of the action is a .netrc file in the home directory of the user running the github runner (overwriting a previous .netrc in the same place). The action configuration is nothing special:

      - name: Commit changes
        uses: EndBug/add-and-commit@v4
        with:
          ref: "test"
          cwd: "test"
          author_name: <my name>
          author_email: <my email>
          message: "Save"
          add: "docs"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The test directory contains the test branch of the repository, and was checked out using Github's actions/checkout.

To convince myself that this action was responsible, I tried with a few different values for GITHUB_TOKEN (setting it to other valid github tokens in my secrets list). That token always ended up in the .netrc file. Needless to say, this behavior is a deal breaker.

I don't know what more information to give you. You can replicate it by using this on your own runner, and checking that a .netrc is created.

ESling not found

Hi !
I ve tried your add with ESLint , but it says
Run eslint "**.html" --fix /home/runner/work/_temp/bbd2754b-0c9c-4db7-8c11-3e0101871637.sh: line 1: eslint: command not found Error: Process completed with exit code 127.

Do you have an idea, please ?

Github errors when pushing a second PR

It worked for the first PR I made but then it kept erroring out.

Run EndBug/add-and-commit@v4
Unable to get commit from workflow event: trying with the GitHub API...
Using 'Bernardo Martinez <[email protected]>' as author.
Running for a PR, the action will use 'bmartinez287-particle' as ref.
Internal logs
error: failed to push some refs to 'https://github.com/UTCWeb/particle'
Task completed.

Here is the config file

`name: Node.js CI

on:
  push:
    branches: [ develop ]
  pull_request:
    branches: [ develop ]

jobs:
  build:

    runs-on: ubuntu-latest
strategy:
  matrix:
    node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
  uses: actions/setup-node@v1
  with:
    node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build:drupal --if-present
- run: npm run build:pl --if-present
- name: Commit changes
  uses: EndBug/add-and-commit@v4
  with:
    author_name: Bernardo Martinez
    author_email: [email protected]
    message: "Compiling assets"
    add: "*"
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`

ref not working

The docs:

    # Name of the branch to use, if different from the one that triggered the workflow
    # Default: the branch that triggered the workflow (from GITHUB_REF)
    ref: 'someOtherBranch'

The reality:

##[warning]Unexpected input(s) 'ref', valid inputs are ['add', 'author_name', 'author_email', 'cwd', 'force', 'message', 'remove']

Also, I thought ref should be set to the branch I want the commit to be pushed, but reading the docs and the code, I'm not really sure what it's supposed to do. What I wanted is to push the change to a different branch than the one it's running on.

Action can only commit once in the same workflow run

If the action is used twice in the same run, and it has to commit in both, it will fail the second time.

Example:

fatal: A branch named 'master' already exists.
Creating and switching branch...
##[error]Docker run failed with exit code 128

This seems to be linked with the fact that the action tries to create a new branch every time it runs and fails if the branch has already been created in previous steps.
It could be fixed by checking for the branch's existence before creating the new one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.