Search code examples
windowsgitgit-pushgithub-actions

GitHub Actions push changes to remote/origin on windows


I want to automate my build process using GitHub Actions, this process has the following steps:

  1. checkout
  2. build
  3. pack
  4. tag
  5. increment version
  6. commit changes
  7. push tags and new commits
  8. push package to a repo

I created this main.yml for GitHub Actions:

name: Build

on:
  repository_dispatch:
    types: build

jobs:
  build:
    name: Run build
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v1
        with:
          ref: 'master'
          token: ${{ secrets.GITHUB_TOKEN }}

      # checkout master, 'cause of detached head
      - name: Checkout master
        run: git checkout master

      # run the build script
      - name: Build
        if: success()
        run: .\build\build.ps1

      # pack everything
      - name: Pack
        if: success()
        run: .\build\pack.ps1

      # tag this version
      - name: Tag
        if: success()
        run: .\build\tag.ps1

      # increment version
      - name: Increment Version
        if: success()
        run: .\build\increment-version.ps1

      # Commit changes
      - name: Add & Commit
        if: success()
        run: |
          git config user.email actions@github.com
          git config user.name "GitHub Actions"
          git commit -a -m "Automated build" --author="GitHub Actions<actions@github.com>"

      # todo: push changes to remote/origin
      - name: Git Push
        if: success()
        run: git push

      # Push package to a repo
      - name: Push Package
        if: success()
        run: .\build\push-package.ps1

I tried to use actions provided by the marketplace, but sadly I have to build this application on a windows machine.
Most of the acions exit with the following error message: ##[error]Container action is only supported on Linux.
The other doesn't work as well, that's why I tried to use the run option.

Unfortunately pushing using this way does work neither. I get this output:

Logon failed, use ctrl+c to cancel basic credential prompt.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)

(I have to cancle the task manually.)

I think I have to provide the {{ secrets.GITHUB_TOKEN }} to the push command, but I only find a way to use a basic auth, but all guides (general guides) I have found using this token as bearer token.

How do I push changes back to origin/remote in a GitHub Actions on windows?


Solution

  • Using GitHub Push by ad-m fixed my issue. I'm pretty sure that I already tested this action.