I run my game on my Github pages.
and recently started using unity cloud builds.
I managed to get the post-build script running.
but have no clue on how to get it to pull the repository, apply the new build, and push it to GitHub.
So far I have tried this script, without much luck
#!/bin/sh
set -x
ssh-agent $(ssh-add ./id_rsa; git clone git#github.com:triktron/Road-Rage.git tmpResp; cp -r ./WebGL/Build ./tmpResp/;cd ./tmpResp/; git add Build; git commit -m "auto build"; git push)
the logs responded with this
2838: Executing Post-Build Script at upload.sh
2839: ###########################################################
2840: # WARNING: UNPROTECTED PRIVATE KEY FILE! #
2841: ###########################################################
2842: It is required that your private key files are NOT accessible by others.
2843: This private key will be ignored.
2844: ++ git clone git#github.com:triktron/Road-Rage.git tmpResp
2845: Cloning into 'tmpResp'...
2846: ++ cp -r ./WebGL/Build ./tmpResp/
2847: cp: ./WebGL/Build: No such file or directory
2848: ++ cd ./tmpResp/
2849: ++ git add Build
2850: ++ git commit -m 'auto build'
2851: *** Please tell me who you are.
2852: Run
2853: to set your account's default identity.
2854: Omit --global to set the identity only in this repository.
2855: ++ git push
2856: Everything up-to-date
2857: + ssh-agent
2858: SSH_AGENT_PID=5387; export SSH_AGENT_PID;
2859: WORKSPACESIZE | ARTIFACTSSIZE
2860: --------------|--------------
2861: 154.10 MiB | 12.79 MiB
thanks already for your time!
[Update 23 march 2020]
so i've spent more time on this then i'm willing to say but i figured it out.
here is my solution if anyone ever wants to do the same.
i placed this script in my files
#!/bin/sh
set -x
export buildfolder="$(find . -regex '.\/temp[^\/]*\/WebGL\/Build' -print -quit)"
if [ -z "$buildfolder" ]; then
echo "Could not find build folder"
exit 1
fi
if [ ! -d ./tmp ]; then
git clone "https://${nickname}:${githubkey}#github.com/${nickname}/${repositorie}" ./tmp
fi
cp -r "$buildfolder" ./tmp
cd ./tmp
git add Build
git config --global user.email "$githubemail"
git config --global user.name "$nickname"
git commit -m "unity cloud build"
git push --force
and added these envirement varibles in my unity cloud build console
picture of envirement vars
Related
Why all the script in my git hooks (pre-commit, post-commit, pre-receive, pre-push etc) do not run?
Note:
this question is not a duplicate;
I have try the answer to each of the other questions but none of them work.
I did chmod +x, added the path to hook. rename script, neither of them solve my issue.
Inside my git
branches config description HEAD hooks info objects refs
Inside hooks:
applypatch-msg.sample fsmonitor-watchman.sample post-update.sample pre-commit prepare-commit-msg.sample pre-rebase.sample update.sample
commit-msg post-merge.sh pre-applypatch.sample pre-commit.sample pre-push pre-receive
I run them manually and they are all working fine.:
$ bash pre-commit
You are about to commit to master
Do you really want to do this? [y/n] y
pre-commit script
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
echo "You are about to commit" $(git diff --cached --name-only --diff-filter=ACM)
echo "to" $(git branch --show-current)
while : ; do
read -p "Do you really want to do this? [y/n] " RESPONSE < /dev/tty
case "${RESPONSE}" in
[Yy]* ) exit 0; break;;
[Nn]* ) exit 1;;
esac
done
But when i git commit and git push to the repository none of the scripts work.
$git commit -m "Test hooks"
[master] Test hooks 1 file
changed, 1 insertion(+)
My git version is 2.39.1
I created the repository on a VM with Ubuntu 18.04.6 LTS installed
Here was the procedure fro creating the repo.
mkdir project1.git
cd project1.git
git init --bare
After the creation i clone the repo to my local computer (windows).
Clone the git repository
git clone git#{ip}:/home/git/git_repositories/project1.git/
But I want use the scripts in project1.git/hooks to make this work.
A pre-commit hook for instance would not work in a bare repository (which has no working tree).
It would work only in your cloned repository, on Windows, where you can create a myClonedRepo/.git/hook/pre-commit script (no extension, no .sh), which will be run before each commit.
From the comments:
all users could create/clone their repositories from a shared Git template repository. The article "Creating a Custom Git Template" gives an illustration of that approach, but means that:
every user must access the same shared folder
they need to activate the init.templateDir config setting in their global Git configuration
any check which must be enforced for all the team members, especially for a distributed team, is best managed by server-side hooks instead.
I want to build a backup system. I have a server (an old pc) and I boot it up via magic packets. For this purpose, I've written a batch Script doing this. On the server is a git server running with a couple of repositories. I can easily push to it.
But here's the problem:
My project folder contains itself a couple of git repositories. If I now add all files with git add . an Error is thrown, that I should add the submodules. This is the post talking about it Automatically Add All Submodules to a Repo. I've modified the shell script, to work with spaces, and to automatically commit and push everything while executing.
cd "D:\Projekts"
find . -type d | while read x ; do
if [ -d "${x}/.git" ] ; then
cd "${x}"
origin="$(git config --get remote.origin.url)"
cd - 1>/dev/null
echo ""
echo git submodule add "${origin}" "${x}"
git submodule add "${origin}" "${x}"
fi
done
echo "done adding all submodules"
git add .
git commit -am "new backup"
git push
echo "done pushing"
And this doesn't throw an error so far. But still the folders containing all those repositories are empty, if I clone the repository.
sidenote: I add the remote to the backup repository like this: $ git remote add --mirror=fetch origin git#<ip>:backup.git
Thanks in advance for your time,
Hellow2 :)
I have a bash script that executes successfully in my local environment:
#!/bin/bash
#build changelog
version="Version: "
current_date=`date`
cat <(printf " \n") <(echo $version $env:BUILD_BUILDNUMBER $current_date) <(tail -n+6 pr-changelog.md) ./CHANGELOG.md > output
mv output ./CHANGELOG.md
However using the the Bash build package in my Azure Devops pipeline, whilst the script succeeds, does not throw any errors and the pipeline completes, the changes in the script do not take place.
The script copies lines from one file to the CHANGELOG.md and a couple of other small things. Locally the text is copied, but after running the pipeline, the CHANGELOG.md file has not changed in my branch.
Can I expect this to work and if not, what further steps should I take?
TIA
Bash script successfully executes locally but not in Azure Devops pipeline
When we execute the build on the Azure pipeline, it will checkout the source from the repo to the build agent and the next operation is also done on the agent. It will not directly affect the repo, this way will protect the security of the source in our repo.
That is the reason why the changes in the script do not take place in your branch.
To resolve this issue, we need to submit this change to the repo by the git command: git add git commit and git push:
git config --global user.email "xxx#xyz.com"
git config --global user.name "Admin"
cd "$(System.DefaultWorkingDirectory)"
version="Version: "
current_date=`date`
cat <(printf " \n") <(echo $version $env:BUILD_BUILDNUMBER $current_date) <(tail -n+6 pr-changelog.md) ./CHANGELOG.md > output
mv output ./CHANGELOG.md
git add CHANGELOG.md
git commit -m "copies lines to CHANGELOG.md"
git push https://<PAT>#dev.azure.com/YourOrganization/YourProject/_git/YourProject HEAD:master
I test it with Azure pipeline, it works fine.
I've created a Python "automation" task that will initialize a repository on github and then on my bash function I'll be creating a folder, initialize the repository as the code bellow shows:
#!/usr/bin/env sh
function repo() {
cd
python C:/Users/wsm/PycharmProjects/GitAutomation/create.py $1
cd C:/Users/wsm/$1
start .
git init
git remote add origin <mygithublink>/$1.git
touch README.md
git add .
git commit -m "Initial commit"
git push -u origin master
code .
}
The only problem is that I have to use source command everytime I close a git bash to enable the command repo (Name of the function) again. Any ideas on how to make that command permanent on Windows 10?
I've this script for macOS that removes temporarily a GIT Hook. This script is triggered by an npm script defined in my package.json. This project is shared across the whole team, so it has to work on every machine.
gitdir="$(git rev-parse --git-dir)"
hook="$gitdir/hooks/post-commit"
# disable post-commit hook temporarily
[ -x $hook ] && chmod -x $hook
git add -A
git commit --amend --allow-empty --no-edit --no-verify
# enable it again
chmod +x $hook
Can someone help me transcribe this to a .bat in order to be able to excute this in windows?