fatal: Commit found, use 'git ftp push' to sync - github

I am getting this error in my circleci yaml file when uploading to my ftp site via my github, there is definitely a change for it to commit but i'm getting this error:
HEAD is now at 76a63d8 Updated config.yml
fatal: Commit found, use 'git ftp push' to sync. Exiting.
..
Even though I have that in my yaml file:
version: 2
jobs:
deploy:
docker:
- image: circleci/node:8-browsers
working_directory: ~/repo
steps:
- checkout
- run: npm install
- run:
name: Deploy Master Branch
command: |
sudo apt-get update
sudo apt-get -qq install git-ftp
echo "Deploying project ..."
git ftp init --user ${username} --passwd ${password} ${ftp_location}
- git reset --hard
- git ftp push
workflows:
version: 2
master-deploy:
jobs:
- deploy:
filters:
branches:
only: main

yes i am also getting the same error and i fixed it with this code
sudo apt-get update
sudo apt-get -qq install git-ftp
git config git-ftp.user ${username}
git config git-ftp.url ${ftp_location}
git config git-ftp.password ${password}
git ftp push
Please follow this code

Related

GitHub Action incapable of pushing due to "unsafe repository" error

I have a private GitHub repository that has a GitHub Action that pushes files which are created at the Action's runtime to the repository. Since yesterday (2022-04-12), the Action fails at the following step:
- name: Push data to repo
uses: github-actions-x/commit#v2.8
with:
push-branch: 'main'
commit-message: 'Add current data'
force-add: 'true'
files: *.zip
name: autoupdate
Running this step triggers the following error message:
Command line: | /usr/bin/git checkout -B main
Stderr: | fatal: unsafe repository ('/github/workspace' is owned by someone else)
| To add an exception for this directory, call:
|
| git config --global --add safe.directory /github/workspace
Based on the error message I added the following to my GitHub Action:
- name: Fix issue with repository ownership
run: |
git config --global --add safe.directory /home/runner/work/vksm/vksm
git config --global --add safe.directory /github/workspace
I have also added /home/runner/work/vksm/vksm as I was not sure if /github/workspace in the error message is meant as a generic path or not. /home/runner/work/vksm/vksm is where the checkout step puts the repository when the Action runs: /usr/bin/git init /home/runner/work/vksm/vksm
The whole sequence of steps is as follows:
steps:
- name: Checkout the repository
uses: actions/checkout#v2
- name: Fix issue with repository ownership
run: |
git config --global --add safe.directory /home/runner/work/vksm/vksm
git config --global --add safe.directory /github/workspace
- name: Set up Python 3.9
uses: actions/setup-python#v2
...
- name: Install dependencies
run: |
pip install requests
- name: Run Python script
run: |
python script.py
- name: Push data to repo
uses: github-actions-x/commit#v2.8
...
However, the error still occurs.
This questions is possibly related to Cannot add parent directory to safe.directory on git.
Windows 10
In my case "Unsafe repository is owned by someone else" resolved by command in mention folder
Use takeown from the command prompt to take ownership a folder, all its subfolders and files recursively.
takeown.exe /f . /r
This works well, but if you don't run your command line console as administrator it may fail for files you don't own.
This is happening because of a security vulnerability. The error is thrown inside the docker container before you can execute the git config commands to fix the unsafe repository problem. You need to modify the entrypoint of the docker container to execute the git command. You can check this link for details about the vulnerability.
A temporary workaround until git/action owners make a change could be to fork/clone the action that uses docker and modify it with something like this.
#!/bin/bash
set -o pipefail
# config
# ...
# Fix the unsafe repo error which was introduced by the CVE-2022-24765 git patches
git config --global --add safe.directory /github/workspace
#...
You can take a look at the comments in this issue for some ideas about a workaround.
I added the whole path to the current project:
git config --global --add safe.directory '/home/user/AndroidStudioProjects/MyRepoNameInc'
Then performed the push
git commit -m "first commit"
I had this issue with GitLab runner. spent hours doing everything. At last, it started to work after updating .gtlab-ci.yml .
Folder permissions were as below
/var/www/html/project - www-data:www-data
/var/www/html/projcect/.git - gitlab-runner:www-data
Updated script as below.
script:
- git config --global --add safe.directory /var/www/html/phase-3/public-ui

How to self-host Read the Docs using GitHub Pages

How can I setup a CI/CD workflow with gitlab (or GitHub Actions) that generates my own Read the Docs site and is hosted for free using gitlab pages?
Is there a fork-ready example repo on gitlab or github that I can use to self-generate and self-host my own Read the Docs site?
You can host a sphinx-powered site (optionally using the Read the Docs theme) on GitHub Pages using GitHub Actions to wrap sphinx-build and push your html static assets to your GitHub Pages source, such as the gh-pages branch..
You need to define a GitHub Actions workflow to execute a build script.
Here's an example workflow that will execute buildDocs.sh every time there's a push to master
name: docs_pages_workflow
# execute this workflow automatically when a we push to master
on:
push:
branches: [ master ]
jobs:
build_docs_job:
runs-on: ubuntu-latest
container: debian:buster-slim
steps:
- name: Prereqs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
apt-get update
apt-get install -y git
git clone --depth 1 "https://token:${GITHUB_TOKEN}#github.com/${GITHUB_REPOSITORY}.git" .
shell: bash
- name: Execute script to build our documentation and update pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: "docs/buildDocs.sh"
shell: bash
And here's an example buildDocs.sh script that's executed by the workflow above:
#!/bin/bash
################################################################################
# File: buildDocs.sh
# Purpose: Script that builds our documentation using sphinx and updates GitHub
# Pages. This script is executed by:
# .github/workflows/docs_pages_workflow.yml
#
# Authors: Michael Altfield <michael#michaelaltfield.net>
# Created: 2020-07-17
# Updated: 2020-07-17
# Version: 0.1
################################################################################
###################
# INSTALL DEPENDS #
###################
apt-get update
apt-get -y install git rsync python3-sphinx python3-sphinx-rtd-theme
#####################
# DECLARE VARIABLES #
#####################
pwd
ls -lah
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
##############
# BUILD DOCS #
##############
# build our documentation with sphinx (see docs/conf.py)
# * https://www.sphinx-doc.org/en/master/usage/quickstart.html#running-the-build
make -C docs clean
make -C docs html
#######################
# Update GitHub Pages #
#######################
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}#users.noreply.github.com"
docroot=`mktemp -d`
rsync -av "docs/_build/html/" "${docroot}/"
pushd "${docroot}"
# don't bother maintaining history; just generate fresh
git init
git remote add deploy "https://token:${GITHUB_TOKEN}#github.com/${GITHUB_REPOSITORY}.git"
git checkout -b gh-pages
# add .nojekyll to the root so that github won't 404 on content added to dirs
# that start with an underscore (_), such as our "_content" dir..
touch .nojekyll
# Add README
cat > README.md <<EOF
# GitHub Pages Cache
Nothing to see here. The contents of this branch are essentially a cache that's not intended to be viewed on github.com.
If you're looking to update our documentation, check the relevant development branch's 'docs/' dir.
For more information on how this documentation is built using Sphinx, Read the Docs, and GitHub Actions/Pages, see:
* https://tech.michaelaltfield.net/2020/07/18/sphinx-rtd-github-pages-1
EOF
# copy the resulting html pages built from sphinx above to our new git repo
git add .
# commit all the new files
msg="Updating Docs for commit ${GITHUB_SHA} made on `date -d"#${SOURCE_DATE_EPOCH}" --iso-8601=seconds` from ${GITHUB_REF} by ${GITHUB_ACTOR}"
git commit -am "${msg}"
# overwrite the contents of the gh-pages branch on our github.com repo
git push deploy gh-pages --force
popd # return to main repo sandbox root
I wrote an article that describes how to run your own Read the Docs site on GitHub Pages that describes the above files in more detail.
I adapted #Michael Altfield's solution into a single GitHub Action:
name: docs_pages_workflow
on:
push:
branches: [ main ]
jobs:
build_docs_job:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout#v2.3.4
- name: Set up Python
uses: actions/setup-python#v2.2.1
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install -U sphinx
python -m pip install sphinx-rtd-theme
- name: make the sphinx docs
run: |
make -C docs clean
make -C docs html
- name: Init new repo in dist folder and commit
run: |
cd docs/build/html/
git init
touch .nojekyll
git add -A
git config --local user.email "action#github.com"
git config --local user.name "GitHub Action"
git commit -m 'deploy'
- name: Force push to destination branch
uses: ad-m/github-push-action#v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
force: true
directory: ./docs/build/html
Note, my Makefile builds to build not _build directory. The last line with directory: is saying to push from the .docs/build/html directory where we just created the new Git repo. This avoids his rsync and pushd commands. Otherwise the logic follows #Michael Altfield's solution.

Github actions scp into VPS via ssh only

This is currently my workflow
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- uses: actions/setup-node#v1
with:
node-version: '10.x'
- run: npm install
- run: npm install -g #angular/cli > /dev/null
- run: ng build --prod
- run: scp -o StrictHostKeyChecking=no -r ./dist/pwa/* user#domain.com://home/user/domain.com/pwa
The above is roughly a translation of what I have on CircleCI. However, obviously the above fails.
CircleCI allowed adding 'SSH Permissions' to a project, so as during setting up build to run, it attaches that to the environment, thus making any ssh commands to the VPS easy.
How can I accomplish a similar approach in Github? Github Actions supports SSH Permissions? If not, is there a workaround?
How do you folks copy files from your workflow builds to an external server via ssh (i.e scp)?
This is what I do, after adding the SSH key to github secrets:
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 700 ~/.ssh/id_rsa
ssh-keyscan -H domain.com >> ~/.ssh/known_hosts
scp -o StrictHostKeyChecking=no -r ./dist/pwa/* user#domain.com://home/user/domain.com/pwa

gitlab ci does not update code at remote server

I want to deploy ma test app from local repo to gitlab repo and with gitlab ci push it to my remote server. SSH connection is working, gitlab CI shows that job is passed, but code on remote server is not updated.
I made bare repo in: /home/repos/testDeploy.git
And folder for files is in: /home/example.com/web/testDeploy
I added
My .gitlab-ci.yml file
stages:
- deploy
deployment:
stage: deploy
environment:
name: production
url: http://www.example.com/testDeploy
only:
- master
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- git remote add production ssh://user#server:port/home/repos/testDeploy.git
- git push -f production master
- echo "Deployed to production!"
Also, i have post-receive hook:
#!/bin/sh
git --git-dir=/home/repos/testDeploy.git --work-tree=/home/example.com/web/testDeploy checkout -f
I make changes in my local repo, commit and push to origin master to gitlab. Job is passed, but as I mention above, file on remote server is not update.
Output from gitlab job is:
Fetching changes...
HEAD is now at 595db67 as
Checking out 595db67b as master...
Skipping Git submodules setup
$ which ssh-agent || ( apt-get update -y && apt-get install openssh- client -y )
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 40589
$ chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ git branch
* (HEAD detached at 595db67)
master
production
$ git push -f production master
Everything up-to-date
$ echo "Deployed to production!"
Deployed to production!
Job succeeded
What I am doing wrong? Can you someone help me please to figure it out? Thank you for all your answers.

Pushing on a Git repository with Travis-CI

I want to execute a script every time I push into the master, this script will create some files that I want to commit and push. The log of the Travis build seems to be adding the files, committing and pushing, but nothing happens.
My .travis.yml is this one:
before_install:
- openssl aes-256-cbc -K $encrypted_290c3b2c061d_key -iv $encrypted_290c3b2c061d_iv -in id_rsa.enc -out /tmp/id_rsa -d
- eval "$(ssh-agent -s)" # Start the ssh agent
- chmod 600 /tmp/id_rsa
- ssh-add /tmp/id_rsa
install:
- wget --user $docencia_ac_username --password $docencia_ac_password http://docencia.ac.upc.edu/FIB/grau/PEC/Protegido/Documentacion/eines-sisa-64BITS.tgz
- tar -xf eines-sisa-64BITS.tgz
- export PATH=$PATH:$(pwd)/eines-sisa/bin
script:
- chmod +x ./compile_to_hex.sh
- "./compile_to_hex.sh"
after_success:
- rm -rf $TRAVIS_BUILD_DIR/tmp/
- git config --local user.name "Marc43"
- git config --local user.email "my mail"
- git add $TRAVIS_BUILD_DIR/hex/*
- git commit -m "At $(date) hex files builded - travis-ci [skip ci]"
- git push git#github.com:Marc43/sisa_hexbuilder.git master > /dev/null 2>&1
before_deploy:
- rm -rf eines-sisa*
in the git user.email it really goes my email but I decided to delete it for the question.
And the travis log for the build is:
$ git add $TRAVIS_BUILD_DIR/hex/*
$ git commit -m "At $(date) hex files builded - travis-ci [skip ci]"
[detached HEAD 10e7e48] At Sun Apr 15 08:06:17 UTC 2018 hex files builded - travis-ci [skip ci]
4 files changed, 21 insertions(+)
create mode 100644 hex/exemple.hex
create mode 100644 hex/joc_io.hex
create mode 100644 hex/tb_branch.hex
create mode 100644 hex/tb_sum.hex
I know that there is another way to do this via GitHub tokens or something like that, anyway I don't know how to do it one way or the other. I've tried to do it with the deploy too but it never uploaded my files, just tagged the same commit I did. Any ideas?
Thank you,
Marc
I run several repositories that need documentation compiling to distributable formats (e.g. AsciiDoc to HTML, MD to PDF), rather than having to build and commit every time I want to update the distributable, I’d like to automate this process. This is where I use TravisCI as a build server.
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
global:
secure: hZJlqgOzA2zIUJSWIka0PylqNaTkfHq+kS48RrHmocrK0vLyCW7ECWrzez2f2RVdTNzPi0b+yJq2uCbFfWjImZqg+XY1I75/CVVdSYMk7PJkYZ/iBDixMYY8CAkRRd5yZft9uZAdZzR4KLCPN18n7qfISv/M9VA8989NKcVyiEU=
push.sh
#!/bin/sh
setup_git() {
git config --global user.email "travis#travis-ci.org"
git config --global user.name "Travis CI"
}
commit_website_files() {
git checkout -b gh-pages
git add . *.html
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
}
upload_files() {
git remote add origin-pages https://${GH_TOKEN}#github.com/MVSE-outreach/resources.git > /dev/null 2>&1
git push --quiet --set-upstream origin-pages gh-pages
}
setup_git
commit_website_files
upload_files
Reference - https://gist.github.com/willprice/e07efd73fb7f13f917ea