Ramon Medeiros
Ramon Medeiros

Reputation: 2631

How I create a job to run after all jobs in Github Actions

In my Github Actions, I'm creating some resources in the cloud, and I want to have a job that clean up all my resources.

I saw that the actions, like checkout, they have a Post action. Do we have a post job?

Upvotes: 5

Views: 3923

Answers (1)

scthi
scthi

Reputation: 2481

You can use if always() to execute a step even if the previous step failed.

Example:

steps:
  - name: Git checkout
    uses: actions/checkout@v2

  ... run tests ...

  - name: Upload Logs
    if: always()
    uses: actions/upload-artifact@v1
    with:
      name: test logs
      path: application.log

See: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#always

Upvotes: 6

Related Questions