This is my action script:
name: Build
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: |
whoami
sudo mkdir /first_org
sudo chmod -R 777 /first_org
cd /first_org
git clone https://github.com/first_org/site
sudo rm -rf /first_org/site/.git
sudo mkdir /second_org
sudo chmod -R 777 /second_org
cd /second_org
git clone https://github.com/second_org/site
cp -a /first_org/site/. /second_org/site
cd /second_org/site
sudo apt-get update
sudo apt install nodejs
npm build
The /first_org/site is a public repo, but the /second_org/site is a private repo.
I don't use action/checkout#v2 because it doesn't let us specify an ABSOLUTE path to clone into. Thus I had to use pure shell commands.
This action belongs to /second_org/site repo, thus based on docs, I can use GITHUB_TOKEN to access it. But none of the examples show how can I use it in a simple git clone command.
How can I use GITHUB_TOKEN in my shell?
You can clone using a token that way in shell (bash):
git clone https://<token>#github.com/<owner>/<repoName>.git
Note that the GITHUB_TOKEN might not have enough scope permission to be used on private repo. In that case, you will need to use a PAT.
Here is an example of an action I created cloning a repo in bash (as reference): https://github.com/GuillaumeFalourd/create-other-repo-branch-action/blob/main/action.yml
Related
I am new to gitlab runners and trying to automate my project so that whenever a new tag is released, it should build a new deb package. PS: I am using mac and
following this official link by gitlab to get my task done
My first gitlab-ci.yml file was(which is just given there on the official link of gitlab I provided above):
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
# Defines stages which are to be executed
stages:
- build
# Stage "build"
run-build:
stage: build
script:
- apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev
- autoreconf -fvi
- cp COPYING debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../goaccess*.deb build/
# This stage is only executed for new tags
only:
- tags
# The files which are to be made available in GitLab
artifacts:
paths:
- build/*
The problem I initially getting with the above gitlab-ci.yml file was:
Output 1:
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 3d71402b as tag1-test...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ source /etc/profile
$ apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
So to resolve the above issue, I thought to change the brefore_script part with this
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
- echo "Hello, $GITLAB_USER_LOGIN!"
- echo "Hello, $GITLAB_USER_PASSWORD"
# - sudo rm /var/cache/apt/archives/lock
# - sudo rm /var/lib/dpkg/lock
- sudo su
Where I am trying to remove /var/cache/apt/archives/lock and /var/lib/dpkg/lock, as this is what I found on Google. When it didn't work, I tried sudo su. But with the above change, I started to get this issue.
Output 2:
Getting source from Git repository
00:00
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 7fbaaf4f as testing4...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ source /etc/profile
$ sudo rm /var/cache/apt/archives/lock
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
It says sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required
So, to resolve this, I used sudo -S su < $password_secret as shown:
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
- echo "Hello, $GITLAB_USER_LOGIN!"
- echo "Hello, $GITLAB_USER_PASSWORD"
# - sudo rm /var/cache/apt/archives/lock
# - sudo rm /var/lib/dpkg/lock
# - sudo su
- sudo -S su < $password_secret
Please note: I have saved $password_secret in Gitlab variables and it's value is $password.secret as someone on google said this can be it's value. I am not sure how true it is.
And now it is giving me this error:
Output 3:
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 0b8ab538 as 26...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
$ source /etc/profile
$ echo "Hello, $GITLAB_USER_LOGIN!"
Hello, user!
$ echo "Hello, $GITLAB_USER_PASSWORD"
Hello,
$ sudo -S su < $password_secret
[sudo] password for gitlab-runner: Sorry, try again.
[sudo] password for gitlab-runner:
sudo: no password was provided
sudo: 1 incorrect password attempt
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
Please note: I have also used the way which is mentioned here
But, I found that usermod is not there for macOS. So I tried using another way which is mentioned here using dscl. But it still showing me the Output 3 only
Now I am fed up and unable to think of any other possible ways to fix this. I think I have tried almost everything released to this issue(which might not be true at all, as there must be some solution for this, I believe). Can anyone please help me with this?
Summary: Basically my main problem is shown in the first output which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?. Rest everything I am doing is to resolve it only.
I am new to gitlab runners and trying to automate my project so that whenever a new tag is released, it should build a new deb package. PS: I am using mac and
following this official link by gitlab to get my task done
My first gitlab-ci.yml file was(which is just given there on the official link of gitlab I provided above):
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
# Defines stages which are to be executed
stages:
- build
# Stage "build"
run-build:
stage: build
script:
- apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev
- autoreconf -fvi
- cp COPYING debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../goaccess*.deb build/
# This stage is only executed for new tags
only:
- tags
# The files which are to be made available in GitLab
artifacts:
paths:
- build/*
The problem I initially getting with the above gitlab-ci.yml file was:
Output 1:
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 3d71402b as tag1-test...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ source /etc/profile
$ apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
So to resolve the above issue, I thought to change the brefore_script part with this
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
- echo "Hello, $GITLAB_USER_LOGIN!"
- echo "Hello, $GITLAB_USER_PASSWORD"
# - sudo rm /var/cache/apt/archives/lock
# - sudo rm /var/lib/dpkg/lock
- sudo su
Where I am trying to remove /var/cache/apt/archives/lock and /var/lib/dpkg/lock, as this is what I found on Google. When it didn't work, I tried sudo su. But with the above change, I started to get this issue.
Output 2:
Getting source from Git repository
00:00
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 7fbaaf4f as testing4...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ source /etc/profile
$ sudo rm /var/cache/apt/archives/lock
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
It says sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required
So, to resolve this, I used sudo -S su < $password_secret as shown:
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
- echo "Hello, $GITLAB_USER_LOGIN!"
- echo "Hello, $GITLAB_USER_PASSWORD"
# - sudo rm /var/cache/apt/archives/lock
# - sudo rm /var/lib/dpkg/lock
# - sudo su
- sudo -S su < $password_secret
Please note: I have saved $password_secret in Gitlab variables and it's value is $password.secret as someone on google said this can be it's value. I am not sure how true it is.
And now it is giving me this error:
Output 3:
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/
Checking out 0b8ab538 as 26...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
$ source /etc/profile
$ echo "Hello, $GITLAB_USER_LOGIN!"
Hello, user!
$ echo "Hello, $GITLAB_USER_PASSWORD"
Hello,
$ sudo -S su < $password_secret
[sudo] password for gitlab-runner: Sorry, try again.
[sudo] password for gitlab-runner:
sudo: no password was provided
sudo: 1 incorrect password attempt
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
Please note: I have also used the way which is mentioned here
But, I found that usermod is not there for macOS. So I tried using another way which is mentioned here using dscl. But it still showing me the Output 3 only
Now I am fed up and unable to think of any other possible ways to fix this. I think I have tried almost everything released to this issue(which might not be true at all, as there must be some solution for this, I believe). Can anyone please help me with this?
Summary: Basically my main problem is shown in the first output which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?. Rest everything I am doing is to resolve it only.
Pretty new to Nektos/act and in general running workflows locally and cant seem to find a solution to a permissions denied error when installing Node version 16. Here is the error I am running into when I run the following:
Command:
act -j release
Error:
docker exec cmd=[mkdir -p /var/run/act/actions/actions-setup-node#v1/] user= workdir=
mkdir: cannot create directory '/var/run/act/actions': Permission denied
Yaml (Example)
name: Release Example
on:
push:
branches: [ master ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
with:
token: ${{secrets.PRIVATE_SECRET}}
- name: Use version 16 of Node.js
uses: actions/setup-node#v1
with:
node-version: '16'
- name: Pre Install
run: echo "//npm.pkg.github.com/:_authToken=${{secrets.GITHUB_TOKEN}}"> ~/.npmrc
- name: Install
run: npm ci
env:
PRIVATE_SECRET: ${{secrets.PRIVATE_SECRET}}
- name: Release
env:
GITHUB_TOKEN: ${{secrets.PRIVATE_SECRET}}
PRIVATE_SECRET: ${{secrets.PRIVATE_SECRET}}
REGISTRY_TOKEN: ${{secrets.PRIVATE_SECRET}}
run: npx semantic-release
What I have tried:
I have tried setting the user to root on the container for example
container:
image: ghcr.io/catthehacker/ubuntu:full-20.04
options: --user root
I have tried setting sudo in steps
- run: sudo chown runner:docker /var/run/docker.sockenter
I have tried passing the secrets via acts flags
I have tried setting the working directory and setting env auth override to true
I have checked issues related to this topic on the repo and it seems like others are facing the same issue but I have not been able to figure out a solution.
NOTE: This is all working on GitHub, but fails locally with the error mentioned above. Trying hard to test locally to not muddy up my repo with broken commits. Any help is greatly appreciated.
Appears to be a bug with the recent release. I confirm that downgrading to 0.2.24 fixed this issue.
https://github.com/nektos/act/issues/935#issuecomment-1035261208
brew remove act
cd $(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula
git checkout 3ab2604b1e630d4eccab40d0e78f29bd912a72b8 -- act.rb
brew install act
brew pin act
git checkout HEAD -- act.rb
act --version # make sure it's 0.2.24
I have Go test file and it needs root privilege to run it (go test). How to set it in Travis ci?
Here is yml:
language: go
sudo: required
go:
- tip
notifications:
email:
on_success: change
on_failure: always
After git push, travis-ci build failing with default configure.
In travis you can use sudo so if you want to run your tests with root permission, change the script section:
script: sudo -E env "PATH=$PATH" go test ./...
Or if you are using a Makefile:
script: sudo -E env "PATH=$PATH" make
script:
- sudo env "PATH=$PATH" npm test
I need help in setting up a bare git repo on an apache web server. I followed the below instructions
$ cd /var/www/htdocs/
$ git clone --bare /path/to/git_project gitproject.git
$ cd gitproject.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
I got these instructions from here
http://git-scm.com/book/en/Git-on-the-Server-The-Protocols.
I try to run
git clone "http://ip-addr/gitproject.git"
, but am not successful and neither the push command works. Do you have any suggestions on what to do next.
At least try it without the double-quotes:
git clone http://ip-addr/gitproject.git
And if it still hangs, check the log of your Apache server, to see if it is contacted at all.