I have this github action:
jobs:
run-server:
name: Run Contract Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- ...
- name: Start Server
run: iex -S mix phx.server
run-tests:
name: Run Tests
runs-on: ubuntu-latest
needs: run-server
...
steps:
- uses: actions/checkout#v2
- name: Run API Tests
id: run-newman
uses: anthonyvscode/newman-action#v1
...
But the server closes before the second job starts. How do I keep the server going while I run the contract tests?
Related
I have a non-gradle root project which should launch child gh action, but can’t figure out how to. File child.yml should generate apk artifact, since android/ dir is app directory.
Project structure:
root
|
--- .github/workflows/root.yml
--- android/
|
___ .github/actions/apk/child.yml
Closest I get was running a yaml on root level:
root.yml
name: use my action
on:
push:
branches:
- ci_test
jobs:
#Build job
test_build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout#v2
- uses: ./android/.github/actions/apk
child.yml
name: Build of dev branch
on:
push:
branches:
- develop
jobs:
#Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout#v2
- uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: '11'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build the app
run: ./gradlew assembleDebug
- name: Upload apk
uses: actions/upload-artifact#v2
with:
name: debug apk
path: ./app/build/outputs/apk/debug/app-debug.apk
But I get an error with doubled "/my-root-dir/my-root-dir"
Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/my-root-dir/my-root-dir/android/.github/actions/child.yaml'. Did you forget to run actions/checkout before running your local action?
I would like to create a CI pipeline with GitHub Action but I have problems. The front end of the project is developed in Vue 3 and uses vitest to run the tests. It's in a folder called "WEB" in the root directory. So I would like to run my tests at each commit in the master branch but it returns this error:
Error: .github#L1
each step must define a `uses` or `run` key
I used the preexisting "Node.js" template and just added the "working-directory" property to specify the "WEB" folder.
Here is my ".yml" file
name: Runs frontend tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
working-directory: ./WEB
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Execute Unit tests
- run: npm ci
- run: npm run test
When you add a - it add an element at the steps array:
You should do it like this:
- name: Execute Unit tests
run: |
npm ci
npm run test
Trying to make a CI pipeline that will bump root package.json and tag repo using a machine user access token, then have another workflow that triggers to make releases.
But currently, the release workflow never seems to fire.
Linke to a example repo https://github.com/labithiotis/ci-tag-release
I've noticed my PAT in github says it's never been used.
version.yml
name: Versioning
on:
workflow_run:
workflows: [CI]
branches: [main]
types:
- completed
jobs:
versioning:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Increment Versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Increment API version
uses: phips28/gh-action-bump-version#master
env:
GITHUB_TOKEN: ${{ secrets.HAL_PAT }}
with:
tag-prefix: v
release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
release:
name: Release Builds
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout#v2
- run: yarn
- run: yarn wsrun -p #kernel/plugin.main -m build
- name: Release Builds
uses: marvinpinto/action-automatic-releases#latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: *
I have two workflows, develop.yml and production.yml.
develop is configured to run on develop:
name: Develop
on:
push:
workflow_dispatch:
branches:
- develop
jobs:
perform-linting:
runs-on: windows-latest
steps:
- name: Checkout repository code
uses: actions/checkout#v2
- name: Setup node
uses: actions/setup-node#v2
with:
node-version: "14.x"
- name: Install base dependencies
run: npm install
- name: Bootstrap
run: lerna bootstrap
- name: Run ESLint
run: lerna run lint
And production is configured to run on master:
name: Production
on:
push:
workflow_dispatch:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo code
uses: actions/checkout#v2
- name: Deploy to Heroku
uses: akhileshns/heroku-deploy#v3.12.12
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
heroku_email: ${{secrets.HEROKU_EMAIL}}
However, pushing changes to develop or master will trigger both of these workflows to run:
In the above scenario, why is production being run when I only pushed to develop?
your configuration effectively says 'run on all pushes, only allow manual dispatch on a particular branch' (though the latter isn't an option it seems).
You probably mean:
develop.yml
name: Develop
on:
push:
branches:
- develop
workflow_dispatch:
production.yml
name: Production
on:
push:
branches:
- master
workflow_dispatch:
My Rust repository containing multiple subfolders.I would like to be able to build and test each of the projects for each pull request or when a new code is pushed to the master. So I created a ci.sh. Performing the action, I get a "Can't open ./scripts/ci.sh" error.
I've checked that ci.sh has been added to the repo.
What's the proper way to designate ci.sh's path?
name: Rust
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Build, test, clippy all
# run: "${{ format('{0}/.github/scripts/ci.sh', github.workspace) }}" <-also can't find script
run: sh ./scripts/ci.sh
Directory Structure:
MY_EXAMPLES
- .github
- workflows
- scripts
- ci.sh
- build.yml
- EXAMPLE_1
- EXAMPLE_2
- EXAMPLE_3
I did the following and it worked.
echo hi > .github/workflows/scripts/ci.sh
name: test
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: test
run: sh .github/workflows/scripts/ci.sh