0

I would like to use actions to build and deploy a webapplication. At the moment I have one worklflow with exactly one job. Inside this job there are multiple steps:

  • Checkout
  • Test
  • Build
  • Deploy

Is this ok? I mean it feels somehow odd to use one workflow and only one job for all of the steps above. Should I use more jobs? The issue is, that they run in parallel and always create a new container...

In addition the steps aren't independent from each other. I can't deploy without building and I can't build without testing and so on...

Is there a better way compared to what I do?

Thanks

R. Richards
  • 24,603
  • 10
  • 64
  • 64
  • To clarify, do you want these steps to be dependent in that order? If you instead want these to run in parallel upon the same event trigger, then each should be set up as a job within the same workflow file. A workflow file is a way to organize jobs that you want to be triggered by the same event. – jidicula Mar 08 '21 at 00:23
  • No I want them to run after each other: dependent. – El Berro Mar 08 '21 at 09:30
  • In that case, you're taking the right approach here. Multiple steps in a single job in a single workflow file is the best way for setting up directives that you intend to 1) be dependent on the previous directive running successfully and 2) be triggered by the same event. – jidicula Mar 08 '21 at 13:41

1 Answers1

0

It sounds like you do need to separate these tasks to different jobs, each with its own steps.

You can use the jobs.<job_id>.needs directive for it, and create dependency between jobs:

jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04

    steps:
    - ...

  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-18.04

    steps:
    - ...

In addition, you might find additional details in this StackOverflow question:
Create dependencies between jobs in GitHub Actions

DannyB
  • 12,810
  • 5
  • 55
  • 65
  • My issue with this approach is: a) I create a new container for basically no reason. b) I lose all files and folders created during the build. c) I just create the very same result right? I thought the advantage in multiple jobs is that they run in parallel. If I use "need" I don`t have this advantage anymore. This is the reason why I am confused. But thank you very much for your answer. – El Berro Mar 10 '21 at 09:53