Running into Nektos/Act error permission denied when running actions locally - yaml

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

Related

Npm commands not running in SSH

I really can't understand why on my machine via SSH I can execute npm commands and in deploy pipeline is not work? Wtf
Starting deploy
Already up to date.
v16.7.0
7.20.3
Deploy end
Result in CircleCI
Starting deploy
Already up to date.
deploy.sh: line 6: node: command not found
deploy.sh: line 7: npm: command not found
Deploy end
version: 2.1
# Define the jobs we want to run for this project
jobs:
pull-and-build:
docker:
- image: arvindr226/alpine-ssh
steps:
- checkout
- run: ssh -o StrictHostKeyChecking=no ubuntu#xx.xx.xx.xx "cd ~/apps/clm/core; sudo bash deploy.sh"
# Orchestrate our job run sequence
workflows:
version: 2
build-project:
jobs:
- pull-and-build:
filters:
branches:
only:
- Desenvolvimento
My bash script
#!/bin/bash
echo "Starting deploy"
cd ~/apps/clm/core
git pull
node -v
npm -v
echo "Deploy end"
Thanks a lot to anyone who helps.
I really don't understand what's going on I've tried looking for everything...
The problem was in the PATH!
ssh -o StrictHostKeyChecking=no xxx#xx.xxx.xx.xx "source ~/.nvm/nvm.sh; cd ~/apps/xxx/xxx; git pull; npm install; pm2 restart core client"

GIT FTP returning 552 error code but there is plenty of storage

I have the following bitbucket YML file which is currently giving me a 552 FTP error code:
image: bitnami/git
​
pipelines:
branches: # Pipelines that run automatically on a commit to a branch can also be triggered manually
live:
- step:
script:
- apt-get update
- apt-get -qq install git-ftp
- git ftp push -u $FTP_USERNAME_LIVE -p $FTP_PASSWORD_LIVE $FTP_URL_LIVE
dev:
- step:
script:
- apt-get update
- apt-get -qq install git-ftp
- git ftp push -u $FTP_USERNAME -p $FTP_PASSWORD -v $FTP_URL
Please ignore the live branch as we haven't updated this yet. it's the dev branch i'm having issues with right now.
I've tried changing the FTP details, checking the storage available on the CPanel account etc and it still wont work and is giving this error. The FTP account is set to unlimited too. Does anyone have any suggestions how to get around this?

How to use GITHUB_TOKEN to clone a private repository?

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

How to integrate CD with CircleCI?

I've been following a lot of tutorials on CI using Python but the tutorials seem to stop there and rarely take the next step to CD. I'm a sole developer as well.
I've setup a project on Github that runs locally on my PC and is not a web app. I've connected it to CircleCI for CI. Here is my config.yml file.
version: 2
jobs:
build:
docker:
- image: circleci/python:3.7
working_directory: ~/repo
steps:
# Step 1: obtain repo from GitHub
- checkout
- run:
name: install dependencies
command: |
sudo apt-get update
pip install -r requirements.txt
- run:
name: run tests
command: |
python -m pytest -v
Everything runs great and I get an email from CircleCI alerting me the build failed when I make a push to master on github and one the of the pytests fail.
So my question, is what is the next step here? I have a few thoughts but am not sure on any of them honestly.
Create separate test and prod versions of the code. Automate updating the prod version when the test version builds with no errors. However, not sure what tools to use for this.
Push to project to Dockerhub. This seems redundant to me though, because Docker would run the same pytests that CircleCI is running. I'm not sure how this would even help with CD at this point.
Could someone please provide some guidance on next steps here?
Currently you have only one job build, so you can add more jobs under the jobs section. So what you want to do here is:
add test
build prod version
Push to Dockerhub
Please use config 2.1 to enable the workflows.
version: 2.1
jobs:
build:
docker:
- image: circleci/python:3.7
working_directory: ~/repo
steps:
# Step 1: obtain repo from GitHub
- checkout
- run:
name: install dependencies
command: |
sudo apt-get update
pip install -r requirements.txt
- run:
name: run tests
command: |
python -m pytest -v
test:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run: echo "do your test here"
build-prod:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run: echo "build your app"
push-to-dockerhub:
docker:
- image: circleci/python:3.7
steps:
- checkout
- setup_remote_docker # this is necessary to use docker daemon
- run: echo "do docker login and docker push here"
workflows:
build-and-push:
jobs:
- build
- test
requires:
- build
- build-prod
requires:
- test
- push-to-dockerhub
requires:
- build-prod
Please make sure we're using requires to run the job only when the required job is finished successfully.
Well definitely I've not tested the config on my end, but it's like above config. You have more configuration documents here - so please take a look for it to make it perfectly work.
https://circleci.com/docs/2.0/configuration-reference/

Travis-ci needs root privilege when using go test, how to set it?

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

Resources