I am currently working on my personal e-commerce project that I am developing with Java/spring boot for the backend and angular for the frontend. Both projects (frontend and backend) are in a single repository on GitHub.
How can I set up single GitHub workflow for both projects ?
Screenshot of my project's repo
CodePudding user response:
Since most actions assume your code is in the root of the project and the working-directory
option doesn't work on job level you can do a little trick.
Assuming you have a directory structure like:
backend/
- gradlew.sh
- src/
frontend/
- package.json
- src
You can:
- create one job for the backend and one for the frontend
- move the subfolders to the root at the beginning of the job
- run commands/actions
This is what this could look like:
jobs:
be:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: mv -f backend/* .
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- run: ./gradlew check
fe:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: mv -f frontend/* .
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm build && npm test
Be careful though: This mv
just moves all contents from the subfolder into the root. If you have some other files in the root that might interfere, you should first clean the root by deleting all files and directories but the backend
directory.