I'm adding GitHub action to my repo that calls make. This is my Makefile:
CP=cp
TEST=test
all: build
image.z:
./make-image.js -d ./root -f image.z
build: image.z
$(TEST) -d dist || mkdir ./dist
$(CP) ./index.{html,js} ./dist
$(CP) ./image.z ./dist
and got an error:
cp: cannot stat './index.{html,js}': No such file or directory
make: *** [Makefile:11: build] Error 1
Error: Process completed with exit code 2.
My makefile works locally.
This is my workflow file:
name: Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout#v2
with:
fetch-depth: 1
- name: setup node
uses: actions/setup-node#v2
with:
node-version: '17'
- name: "deps"
run: "npm ci"
- name: "build"
run: "make"
- name: upload
uses: betanzos/scp-upload#v1
with:
source: "./dist/*"
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
recursive: 'true'
key: ${{ secrets.SSH_KEY }}
remote_dir: '~/websites/terminal/fake/'
Found the answer on SuperUser Bash extended globbing inside a Makefile
It seems that the Make in GitHub action is using sh by default. Adding:
SHELL=/bin/bash
to Makefile solved the issue
Related
I have following workflow in github action. I am using newman to run my postman collection.
Here what I want to do
Run newman and then store into gh-pages branch. but at the same time I want to store previous report too.
For now it's storing only one report with the name index.html.
name: User workflow
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
- name: Get Previous Report history
uses: actions/checkout#v2
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Install HTML extra reporter
run: |
npm install -g newman
npm install -g newman-reporter-htmlextra
- name: Run Pets Profile API automated test on Dev or Stage
run: |
newman run users/user_pet_postman_collection.json \
-e users/user_env_postman_collection.json \
-g users/user_postman_globals.json \
-r cli,htmlextra
- name: Archive test report
uses: actions/upload-artifact#v3
with:
name: Newman-Report-${{ github.run_id }}-${{ github.run_attempt }}
path: newman/**/*.html
retention-days: 30
- name: Rename report
if: always()
run: |
ls
pwd
cd newman
mv *.html index.html
- name: Host Report on GH pages
if: always()
uses: crazy-max/ghaction-github-pages#v3
with:
target_branch: gh-pages
build_dir: newman
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy report to Github Pages newman directory
if: always()
uses: peaceiris/actions-gh-pages#v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: newman
I have the following deploy.yml
name: Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Copy repository contents via scp
uses: appleboy/scp-action#master
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
PASSWORD: ${{ secrets.PASSWORD }}
with:
source: "."
target: "/var/www/html/cnaiapp"
rm: true
- name: Executing remote command
uses: appleboy/ssh-action#develop
with:
host: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
PASSWORD: ${{ secrets.PASSWORD }}
script: cd /var/www/html/cnaiapp && npm run deploy
However, the master branch has unminified and testing code, that I don't want to have in my VPS. Do you know how could I achieve this? BTW, in order to remove this unnecessary code, I'd need to run the npm run build command.
PS: The npm run deploy command just builds the code and starts the server.
Just add a new step with the run command after checkout:
…
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: build
run: npm run build
- name: Copy repository contents via scp
…
Is it possible to access a github secret in a yaml file that's not a workflow or an action yaml file?
For example, I've saved in github the environment secret INFURA_RINKEBY_WSS and I attempt to access it in the following yaml config file for my program.
type: EndpointList
endpoints:
- type: RPCEndpoint
chain_id: 1
network: rinkeby
provider: Infura
url: ${{ secrets.INFURA_RINKEBY_WSS}}
explorer: https://etherscan.io
However, the INFURA_RINKEBY_WSS environment variable I've set in github isn't accessed yet by my yaml config file.
The following is my main.yaml github workflow:
name: Report to eth/usd on rinkeby w/ pytelliot
on: push
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout#v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python#v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install telliot-feed-examples
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Move pre-made pytelliot configs to home directory
run: |
cp -r ./config ~/
- name: report :)
run: telliot-examples --legacy-id 1 report --submit-once
env:
PK: ${{ secrets.PK }}
INFURA_RINKEBY_WSS: ${{ secrets.INFURA_RINKEBY_WSS }}
Thanks!
I'm trying to copy a jar via SCP in a GitHub Action which I build with maven in the step before.
My problem is, that the SCP step never finds the jar file and fails. Any idea how I can fix/realize this, so the step finds the file?
This is the error I get:
Error: localFile does not exist at /home/runner/work/rest-api/rest-api/target/RestApi.jar
This is what my workflow looks like:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Build
run: |
mvn clean package
- name: Deployment
uses: garygrossgarten/github-action-scp#release
with:
local: "/home/runner/work/rest-api/rest-api/target/RestApi.jar"
remote: "/opt/rest-api/"
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.PASSWORD }}
Thanks in Advance
Ael
Try to use GitHub Actions but getting error when trying to run executable build. I can find executable when doing ls and also changing mod of file executable but didn't got anything. Attached log/output of GitHub action.
Here is my github action workflow file
on:
push:
branches:
- master
name: Build For platforms
jobs:
build:
# We want to define a strategy for our job
strategy:
# this will contain a matrix of all of the combinations
# we wish to test again:
matrix:
go-version: [1.14.x]
platform: [ubuntu-latest]
# Defines the platform for each test run
runs-on: ${{ matrix.platform }}
# the steps that will be run through for each version and platform
# combination
steps:
# sets up go based on the version
- name: Install Go
uses: actions/setup-go#v2
with:
go-version: ${{ matrix.go-version }}
# checks out our code locally so we can work with the files
- name: Checkout code
uses: actions/checkout#v2
- name: Download modules
run: go mod download
- name: Build
run: go build -o executable main.go
- name: Chmod
run: chmod +x executable
- name: List Files
run: ls && pwd
- name: Run
run: ./executable