How to address the artifact I want to upload? - github

I am using Actions to compile an executable and then upload it:
name: note
on: push
jobs:
cli:
runs-on: windows-latest
defaults:
run:
working-directory: ./cli
steps:
- uses: actions/checkout#master
- run: go build -v
- run: dir
- name: upload cli.exe
uses: actions/upload-artifact#v2
with:
name: cli.exe
path: cli.exe
This results in:
The dir command shows that cli.exe is there, but it seems that I do not address it correctly for the upload. How to fix that?

The path of the upload must be provided from the root of the checked-out repo. In my case, the upload section needs therefore to be
- name: upload cli.exe
uses: actions/upload-artifact#v2
with:
name: cli.exe
path: cli/cli.exe
In other words, actions/upload-artifact does not take into account the working-directory setting.

Related

I can't able to upload an artifact to GitHub

there I am facing some issues with my workflow artefacts. The Error is
-(Error: Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts )
I create a zip and then upload it to artefacts does not work. and I delete my old artefacts still I'm facing this issue. I tried so many ways to upload artefacts but nothing worked for me.
I'm sharing my workflow:
name: Build and Deploy My App
on:
push:
branches: [master]
workflow_dispatch:
jobs:
build:
name: Creating Build ⚒
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#main
- name: setup Node Version To 16
uses: actions/setup-node#v2
with:
node-version: '16.x'
- name: Installing Packages 📦
run: npm install --legacy-peer-deps
- name: 🔨 Build Project
run: CI=false npm run build
- name: zip the build folder
run: zip release.zip ./build/** -r
- name: Archive production artifact
uses: actions/upload-artifact#v3
with:
name: my-app-build
path: release.zip
deploy:
name: Start The Deploying 🚀🤘
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact#v3
with:
name: my-app-build
- name: unzip the build folder
run: unzip my-app-build
- name: All Good To Go ✔ start Sync files to hosting
uses: SamKirkland/FTP-Deploy-Action#4.3.3
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}

Github action pointing to a different directory than the current directory

When running an action during a pull request the path emitted by mkdir while trying to create a folder was different than the current directory set by a previous step. This also continues to the next steps as follows..
name: Publish demo
on:
push:
branches:
- 'develop'
pull_request:
branches:
- 'develop'
jobs:
web-deploy:
name: Deploy
runs-on: windows-latest
steps:
- name: Get latest code
uses: actions/checkout#v3
- name: Setup MSBuild
uses: microsoft/setup-msbuild#v1
- name: Setup NuGet
uses: NuGet/setup-nuget#v1.1.1
- name: Navigate to Workspace
run: cd ${{ github.workspace }}/demo_project
- name: Create Build Directory
run: mkdir _build
- name: Restore Packages
run: nuget restore demo_project.csproj
- name: Build Solution
run: |
msbuild.exe demo_project.csproj /nologo /nr:false /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:platform="Any CPU" /p:configuration="Release" /p:PublishUrl="_build"
- name: Sync files
uses: SamKirkland/FTP-Deploy-Action#4.3.3
with:
local-dir: "_build"
server: <server>
username: <username>
password: ${{ secrets.password }}
So, in this line..
run: mkdir _build
the _build folder should be created in demo_project but instead it gets created in ${{ github.workspace }} which i think means that setting the current directory here..
run: cd ${{ github.workspace }}/demo_project
which in turn prints out this in job view..
Run cd D:\a\demo_solution\demo_solution/demo_project
and..
Input file does not exist: D:\demo_project.csproj.
did not take effect. So, what am i missing?
you could specify a different working directory for a job:
You can provide default shell and working-directory options for all run steps in a job
jobs:
web-deploy:
name: Deploy
runs-on: windows-latest
defaults:
run:
shell: bash
working-directory: ${{ github.workspace }}/demo_project
steps:
- name: Get latest code
uses: actions/checkout#v3

Github actions: Re-usable workflows

So what I am trying to do is to organize my ci workflow. I have a self-hosted runner that is my personal computer. Since the workflow files is getting too large I am thinking about reducing the size by having different workflow files instead.
so this is my files so far:
name: "Pipeline"
run-name: ${{ github.actor }} just pushed.
on:
schedule:
- cron: "0 2 * * *"
push:
branches-ignore:
- "docs/*"
tags:
- "v*"
workflow_dispatch:
inputs:
cc_platform:
description: "Input of branch name to build metalayers."
required: true
default: "dev"
jobs:
build:
runs-on: self-hosted
name: Build job.
steps:
- name: Checking out the repository.
uses: actions/checkout#v3
- name: Settings Credentials.
uses: webfactory/ssh-agent#v0.6.0
with:
ssh-private-key: ${{ secrets.SSH_KEY_CC }}
- name: Creating config file.
run:
touch conf
- name: Removing old folders & running build script.
run: |
if [[ -d "my_folder" ]]; then rm -rf my_folder; fi
./build
- name: Generate a zip file of artifacts.
uses: actions/upload-artifact#v3
with:
name: art_${{ github.sha }}
path: |
.*.rootfs.wic.xz
.*.rootfs.manifest
if-no-files-found: error
so what I want to do it to have the artifacts and the build step in their own workflow file. But it does give me som concersn.
Will each workflow file get run in their own runner?
Do they share memory?

lint specific folder using MegaLinter when there is a new push to the specific folder in github actions

I am pretty new for github actions workflow. I have the following question.
What I have:
Have a repo with subfolders folder1/dotnet and folder2/dotnet
What I want to Achieve:
I want to crate github workflow which will lint only folder1 and folder 2 when new code is pushed to specific folder
Currently bellow code lints entire repo
name: pr_dotnet
on:
push:
paths:
- "folder1/dotnet/**"
- "folder2/dotnet/**"
jobs:
lint:
name: Lint dotnet specific folders
runs-on: ubuntu-latest
strategy:
matrix: { dir: ['/folder1/dotnet', 'folder2/dotnet'] }
steps:
- name: Checkout code
uses: actions/checkout#v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/dotnet#v6.12.0
working-directory: ${{matrix.dir}}
- name: Archive linted artifacts
if: ${{ success() }} || ${{ failure() }}
uses: actions/upload-artifact#v2
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
You can run MegaLinter with a sub-workspace as root using variable DEFAULT_WORKSPACE
DEFAULT_WORKSPACE: mega-linter-runner
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/dotnet#v6.12.0
env:
DEFAULT_WORKSPACE: ${{matrix.dir}}
As MegaLinter won't browse at upper lever than DEFAULT_WORKSPACE, you may need to define one .mega-linter.yml config files by root workspace, or use EXTENDS to store the shared configuration online

Artifacts not getting uploaded during Github Actions Build for a MEVN app

As the title suggests, I am building a MEVN (Vue) Stack application and am facing this issue:
Earlier to this, I had been only building the frontedn part of my app & it was successfully getting deployed. Only when did I integrate my backend & changed the folder structure a bit, did I start getting these errors.
Below is my Deploy.yml :
name: Deploy
on:
push:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout#v2
- name: Setup Node
uses: actions/setup-node#v1
with:
node-version: 16
- name: Install dependencies
uses: bahmutov/npm-install#v1
- name: Build project
run: npm run build --prefix client
- name: Upload production-ready build files
uses: actions/upload-artifact#v2
with:
name: production-files
path: ./dist
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download artifact
uses: actions/download-artifact#v2
with:
name: production-files
path: ./dist
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages#v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
Please help.