Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The action passes… but nothing is written on the file #2

Open
eRouge-ps opened this issue May 26, 2020 · 6 comments
Open

The action passes… but nothing is written on the file #2

eRouge-ps opened this issue May 26, 2020 · 6 comments

Comments

@eRouge-ps
Copy link

Hey,

so I’ve managed to make this action work (very basic : go to branch, write something) :

`name: Append File
on:
pull_request:
types: [labeled, unlabeled]

jobs:
build:
name: Append Text
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: writefile
- name: Write File
uses: DamianReeves/[email protected]
with:
path: ${{github.workspace}}/test
contents: |
echo "Hello World!"
write-mode: overwrite`

The action is a success, but the file does not change at all… maybe I need to commit every thing ? I have no clue. If you have an idea I’d love to hear it !

Thanks a lot !

@Glazomer
Copy link

Did u solved it?

@leonstafford
Copy link

leonstafford commented Feb 4, 2021

@eRouge-ps, please edit your issue to use ```, rather than `, as this will format your multiline code sample properly

example:

name: Append File
on:
pull_request:
types: [labeled, unlabeled]

jobs:
build:
name: Append Text
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: writefile
- name: Write File
uses: DamianReeves/[email protected]
with:
path: ${{github.workspace}}/test
contents: |
echo "Hello World!"
write-mode: overwrite

@DamianReeves
Copy link
Owner

Hey,

so I’ve managed to make this action work (very basic : go to branch, write something) :

`name: Append File
on:
pull_request:
types: [labeled, unlabeled]

jobs:
build:
name: Append Text
runs-on: ubuntu-latest
steps:

  • uses: actions/checkout@v2
    with:
    ref: writefile
  • name: Write File
    uses: DamianReeves/[email protected]
    with:
    path: ${{github.workspace}}/test
    contents: |
    echo "Hello World!"
    write-mode: overwrite`

The action is a success, but the file does not change at all… maybe I need to commit every thing ? I have no clue. If you have an idea I’d love to hear it !

Thanks a lot !

So with YAML formatting matters so given what you have there its hard to debug, if you are still having an issue could you properly format the comment?

@FerhatPflegia
Copy link

FerhatPflegia commented May 21, 2021

I have currently the same issue. Is it solved? Mine looks like this:

name: Write commit hash and message in enviroment
uses: DamianReeves/[email protected]
with:
  path: ${{ github.workspace }}/.env
  contents: |
    echo "MESSAGE={{ github.event.head_commit.message }}"
  write-mode: append

@mifriis
Copy link

mifriis commented Sep 30, 2021

Hi all,
You need to run through the process of pushing the file afterwards

      - run: git config --local user.email "[email protected]"
      - run: git config --local user.name "GitHub Action"
      - run: git add scores
      - run: git commit -m "file updated"
      - run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@alexandre97costa
Copy link
Contributor

As the owner said, you need to commit and push the file. If you're not comfortable with running git commands, this action will do it for you:

name: Overwrite file

on:
  push:
    branches: [ main ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v3
        
      - name: Overwrite ip.js
        uses: "DamianReeves/[email protected]"
        with:
          path: path/to/file.js
          write-mode: overwrite
          contents: |
            some content you want to change
            
      - name: Commit & Push
        uses: Andro999b/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: main
          force: true
          message: 'Overwritten by Github Actions - ${date}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants