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

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.

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 executes an action one at the end of the other

I have the following two actions, how can I make the second action be executed at the end of the first after making the first one commit and push?
Action1
on:
workflow_dispatch:
inputs:
name: Scrape Data
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run action
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub sets this for you
Action2
on:
workflow_dispatch:
inputs:
name: Visit Data
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run visit
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub sets this for you
You could use the workflow_run trigger on the second workflow.
Example:
name: Visit Data
on:
workflow_run:
workflows: ['Scrape Data'] # First workflow name
types:
- completed # can also use 'requested'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run visit
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Note that you can't use workflow inputs in that case (I observed you had it set, and if it's necessary you would need to use another trigger, for example through the Github API using a workflow dispatch event with a payload).

how to run GitHub Action after outage?

As you may (or may not) know yesterday was a major incident of GitHub's services: https://www.githubstatus.com/incidents/tyc8wpsgr2r8.
Unfortunately I published a release during that time and the action responsible for building and publishing the code didn't trigger.
For actions which were executed at least once I have an option to "Re-run workflow" - but how can I proceed with an action which didn't even trigger - I can not see it anywhere whatsoever?
I think the last resort would be to just make another release, remove the problematic one etc. but I'd like to avoid that.
The workflow file:
name: Node.js CI
on:
push:
branches: [master]
release:
types: [published]
pull_request:
branches: [master]
jobs:
test:
name: Test Node.js v${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 16
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install --production=false --no-package-lock
- name: Lint 💅🏻
run: npm run lint
- run: npm test
release:
name: Publish NPM Package
if: startsWith(github.ref, 'refs/tags/')
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm install --production=false --no-package-lock
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
gh-pages:
name: Publish GitHub Pages
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
needs:
- test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Install ✔️
run: npm install --production=false --no-package-lock
- name: Build storybook 🏗️
run: npm run build-storybook
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action#4.1.3
with:
branch: gh-pages
folder: storybook-static
As you said in the comment, the easiest solution would be to remove the release and create it all over again.
Another option could be to add a workflow_dispatch event trigger to the workflow with a tag input, updating the jobs condition to use this input.tag variable if informed.
That way, if an automatic trigger failed (through push, release or pull_request), you could trigger it manually through the Github UI or the GH CLI as an alternative.

GitHub Actions: share common actions between jobs

Switching from Travis CI to GitHub Actions, I was wondering if there is a way to share common steps between jobs. For a project, I need each job to start with 3 actions: check out repository code, install Node.js v12, restore node_modules from the cache (if available). Actually I have added these 3 actions for each job, which works but is a bit verbose. Is there a way to say: "Each job must run these actions first" or something like that?
name: ci
on: [push, workflow_dispatch]
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm install
test_mysql:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Test MySQL 5
run: npm run test-mysql
env:
DOCKER_MYSQL_TAG: 5
- name: Test MySQL 8
run: npm run test-mysql
env:
DOCKER_MYSQL_TAG: 8
test_postgres:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Test Postgres 10
run: npm run test-postgres
env:
DOCKER_POSTGRES_TAG: 10
- name: Test Postgres 11
run: npm run test-postgres
env:
DOCKER_POSTGRES_TAG: 11
- name: Test Postgres 12
run: npm run test-postgres
env:
DOCKER_POSTGRES_TAG: 12
test_mariadb:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Test MariaDB 10.4
run: npm run test-mariadb
env:
DOCKER_MARIADB_TAG: 10.4.12
test_mssql:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Test MSSQL 2017
run: npm run test-mssql
env:
DOCKER_MSSQL_TAG: 2017-CU17-ubuntu
- name: Test MSSQL 2019
run: npm run test-mssql
env:
DOCKER_MSSQL_TAG: 2019-latest
test_sqlite:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Test SQLite
run: npm run test-sqlite
publish:
runs-on: ubuntu-latest
needs: [test_mysql, test_postgres, test_mariadb, test_mssql, test_sqlite]
steps:
- name: Check out repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: '12'
- name: Restore node_modules
id: cache-node-modules
uses: actions/cache#v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Build
run: npm run build
- name: Check version changes
uses: EndBug/version-check#v1
id: check
- name: Publish
if: steps.check.outputs.changed == 'true' && github.ref == 'refs/heads/master'
run: |
npm set registry "https://registry.npmjs.org"
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_PUBLISH_TOKEN }}
npm publish
Now is possible to use uses in composite actions - please check this link
Composite action:
name: "Publish to Docker"
description: "Pushes built artifacts to Docker"
inputs:
registry_username:
description: “Username for image registry”
required: true
registry_password:
description: “Password for image registry”
required: true
runs:
using: "composite"
steps:
- uses: docker/setup-buildx-action#v1
- uses: docker/login-action#v1
with:
username: ${{inputs.registry_username}}
password: ${{inputs.registry_password}}
- uses: docker/build-push-action#v2
with:
context: .
push: true
tags: user/app:latest
And then:
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: my-org/publish-docker#v1
with:
registry_username: ${{secrets.REGISTRY_USERNAME}}
registry_password: ${{secrets.REGISTRY_PASSWORD}}
Original reply:
It looks that at the moment is not possible if among steps you want to share are uses.
It should be handled by composite actions but
What does composite run steps currently support?
For each run step in a composite action, we support:
name
id
run
env
shell
working-directory
In addition, we support mapping input and outputs throughout the action.
See docs for more info.
What does Composite Run Steps Not Support
We don't support setting conditionals, continue-on-error, timeout-minutes, "uses", and secrets on individual steps within a composite action right now.

Invalid Workflow File

I get error: "a step cannot have both the uses and run keys", but I don't see that one step have both uses and run. Can someone help me figure it out what is wrong with this?
on:
pull_request:
branches:
- master
env:
IMAGE_NAME: api
jobs:
build:
name: Application build
runs-on: ubuntu-latest
steps:
- name: Checkout repository (#1)
uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Build API
run: dotnet build --configuration Release
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository (#2)
uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Run API Tests
run: dotnet test
auto-approve:
name: Auto approve pull request
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action#v2.0.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
automerge:
runs-on: ubuntu-latest
steps:
- name: automerge
uses: "pascalgn/automerge-action#ccae530ae13b6af67a7a2009c266fe925844e658"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
docker-build:
runs-on: ubuntu-latest
steps:
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
docker-deploy:
runs-on: ubuntu-latest
steps:
- name: Push Docker image to registry
uses: jerray/publish-docker-action#master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: docker.pkg.github.com
repository: jerray/publish-docker-action
auto_tag: true