How to push updated files to GitHub from GitHub Actions - github

I have tried a lot of things but i keep getting this error:
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
This is my action:
- uses: actions/checkout#v2
- name: Commit new version
run: |
git config --global user.name "github-actions[bot"
git config --global user.email "41898282+github-actions[bot]#users.noreply.github.com"
git add -A
git commit -m "Bumping version number"
git push

I fixed it by explicit setting the ref to a branch name. This is not really what i want but will do for now
- uses: actions/checkout#v2
with:
with:
ref: expo-build

Related

How to trigger a github action when a github action push code

I have build a github action, which config as
name: clock-in
on:
workflow_dispatch:
push:
paths:
- 'src/github/log/*'
jobs:
clock-in:
runs-on: ubuntu-latest
steps:
- ...
- run: ./src/github/push.sh
and the push.sh
#! /bin/bash
remote_repo="https://${GITHUB_ACTOR}:${GH_TOKEN}#github.com/${GITHUB_REPOSITORY}.git" # remote repo address
git config user.email "41898282+github-actions[bot]#users.noreply.github.com"
git config user.name "GitHub Actions"
git add .
git commit -m "update clockin log 😎"
git push
I wish that the github action can be triggered when 'src/github/log/*' file changed and pushed. however, when I make a push, it work normally, but when github action push the change, the new acion is not triggered. How I can make the action triggered when the push comes from github action

GitHub Actions: Move branch to another branch

So I'm working on a project where I have a number of Sass stylesheets, and I want to host it on GitHub Pages. I've pointed Pages to the gh-pages branch, and when I make a change I am trying to set up Actions to 'teleport' that branch to my freshly-pushed main source code branch, make a commit containing the generation of new CSS files from the Sass source code, and push that to the gh-pages branch for Pages to host. This way I know it has started from the latest version of the source, with no leftover generated files, and run a single deterministic compilation to create the CSS files I'm after.
I've been able to set this up, but the only way I've been able to get it working is by deleting the gh-pages branch, checking out the main branch, recreating gh-pages and committing from there. The problem with this is that, when the gh-pages branch gets deleted, GitHub Pages stops tracking it and moves back to the main branch. Here's the workflow anyway, just for reference:
name: Compile Sass
on:
push:
branches:
- main
jobs:
build_css:
runs-on: ubuntu-latest
steps:
- name: Checkout source Git branch
uses: actions/checkout#v2
with:
ref: main
fetch-depth: 10
submodules: true
- name: Delete gh-pages branch
uses: dawidd6/action-delete-branch#v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: gh-pages
- name: Create fresh gh-pages branch
uses: peterjgrainger/action-create-branch#v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'gh-pages'
- name: Checkout new gh-pages branch
uses: actions/checkout#v2
with:
ref: gh-pages
fetch-depth: 1
- name: Compile CSS from SCSS files
uses: gha-utilities/sass-build#v0.4.5
with:
source: styles/index.scss
destination: styles/index.css
- name: Add and commit changes to gh-pages branch
run: |
git config --local user.email 'action#github.com'
git config --local user.name 'GitHub Action'
git add styles/*
git commit -m 'Compile website'
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
Solutions I've tried using git rebase and git reset haven't worked for a range of reasons, and I've found that the former (using git rebase --onto main gh-pages gh-pages) works on my local machine but not in CI.
I feel like this must be a reasonably normal thing to want to do, so are there any more widely-accepted methods that I've missed?

I can't push to branch "dev" in Github using CircleCi

I am trying to configure autopush to the branch dev in github, using CircleCi. The problem is that I get an error like:
"error: src refspec dev does not match any.
error: failed to push some refs to 'git#github.com:myname/repo.git'.
Exited with code 1".
When I am using git remote -v, I can see:
origin git#github.com:myname/repo.git (fetch)
origin git#github.com:myname/repo.git (push)
And on the github required branch "dev" exists. Below you can see the part of my *yml code for CircleCi that makes everything.
- run:
name: Git config email
command: git config --global user.email "name#mail.ru"
- run:
name: Git config name
command: git config --global user.name "Name"
- run:
name: git remote -v
command: git remote -v
- run:
name: Push to dev
command: git push origin dev --force
git checkout dev and refs/heads/dev appeared, but the command git push origin dev do not pushed changes into git branch "dev".
That would create a local dev branch based by default on origin/dev.
You would need to merge my_branch to dev first before pushing
git merge my_branch
git push
(git push should be enough, since the newly local created branch dev has origin/dev for its upstream branch)

How to update code in gitlab

My team committed code to gitlab repository and I need to take those updates. I already clone the project into my local directory but didn't take update before.
For taking update what commands need to run. I already tried pull command and it shows the changed file details but that changes are not applying to the project. For apply the changes any new command needs to run again?
Run following commands for taking the update:
git fetch && git checkout master
git pull
git config --global user.name "demo"
git config --global user.email "demo#gmail.com"
Create a new repository:
git clone https://gitlab.com/demo_test.git
cd demo_test
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Push an existing folder:
cd existing_folder
git init --initial-branch=main
git remote add origin https://gitlab.com/demo_test.git
git add .
git commit -m "Initial commit"
git push -u origin main
Push an existing Git repository:
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/demo_test.git
git push -u origin --all
git push -u origin --tags

Error Deploying Artifact to Github from VSTS

I am trying to build maven project in VSTS using hosted agent.
I want to deploy my artifact to github. task i am using is Powershell. i am getting error "There is no tracking information for the current branch".
but artifcat are deploying to github, But Build Defination is failing.
If the github repo is not empty and you want to keep the commit histories, you can use the script as below:
cd $(Build.ArtifactStagingDirectory)
git init
git config --global user.name name
git config --global user.email ***#gmail.com
git add .
git commit -m "update"
git remote add origin https://username:password#github.com/username/reponame -f
git checkout -b temp
git checkout master
git reset --hard origin/master
git merge temp -X theirs --allow-unrelated-histories
git push -u origin master
If the github repo is empty or you don’t need to keep the commit histories, you can use the script as below:
cd $(Build.ArtifactStagingDirectory)
git init
git config --global user.name name
git config --global user.email ***#gmail.com
git add .
git commit -m "update"
git remote add origin https://username:password#github.com/username/reponame -f
git push -f origin master
And deselect Fail on Standard Error option: