AkashNayak6 / writing-javascript-actions

https://lab.github.com/githubtraining/github-actions:-writing-javascript-actions
MIT License
0 stars 0 forks source link

Create a workflow #4

Closed AkashNayak6 closed 3 years ago

AkashNayak6 commented 3 years ago

create a workflow

github-learning-lab[bot] commented 3 years ago

Our workflow has finished πŸŽ‰

Our workflow has finished so let's take a look at the results now that we have learned a little bit about workflows while we waited.

Workflow results screen showing status of each job

In the left-hand panel of this screen you can see that this workflow, named CI was triggered on: push and ran the job titled build.

The right-hand panel shows real-time logging of the steps executed by the build job. There are currently 5 steps defined for this job:

πŸ€”This is interesting, in the my-workflow.yml file we defined 3 steps, not 5, so what happened?

GitHub Actions will always add the Set up job and Complete job steps to each job in a workflow. These steps are what configure the virtual environment before running your steps and shut it down properly before moving onto the next job in your workflow.

If you recall, we had 1 step that used an action and 2 steps that ran commands, can you identify which step used the action?

Answer to above question If you said `actions/checkout@v1` you'd be correct πŸ˜„!

If you want to see this for yourself head over to your [Actions tab]() and examine the workflow named CI

github-learning-lab[bot] commented 3 years ago

Edit the current workflow

Currently my-workflow.yml is not set up correctly for our use-case. It worked great for allowing us to take a high-level look at workflows, but if we want to use our custom actions there are some changes that we have to make to it.

:keyboard: Activity: Modify my-workflow.yml to remove boilerplate steps

  1. Edit the my-workflow.yml to have the following contents:

    name: JS Actions
    
    on: [push]
    
    jobs:
      action:
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v1
  2. Commit these file changes to this branch

I'll respond in this pull request once you make these changes.

github-learning-lab[bot] commented 3 years ago

Finishing the workflow

@AkashNayak6 you're doing great so far πŸ˜„! You've had to do a lot of workflow set up so we can begin writing custom actions. We have just one more thing to add to our my-workflow.yml file before we get to the action side of things.

Recap

Before we make our final workflow change let's do a quick recap about what we've done.

Action Key Takeaways
Created my-workflow.yml inside of .github/workflows directory GitHub repositories look in the .github/workflows folder for workflow files.
Used a templated workflow GitHub provides many templates for workflow files. This is a great spot to look when setting up a new workflow. If you can't find what you are looking for, you can always click the setup a workflow yourself button for a minimal starter template
Workflow environment You learned, from a high level, how a repository uses a workflow file to run commands or actions based on triggers. You also learned that where these commands or actions execute is something that can be specified
Workflow syntax You were briefly introduced to the workflow YAML syntax.

If that seems like a lot of things just to get started... well, it is! GitHub Actions is a robust platform designed to automate a wide range of tasks for your repositories.

If you'd like to see more examples of workflows and actions then check out these Learning Lab courses all about GitHub Actions:

:keyboard: Activity: Modify my-workflow.yml to run our custom action

  1. Edit the my-workflow.yml to contain the following:

    name: JS Actions
    
    on: [push]
    
    jobs:
      action:
    
        runs-on: ubuntu-latest
    
        steps:
        - uses: actions/checkout@v1
    
        - name: hello-action
          uses: ./.github/actions/hello-world
  2. Commit these file changes to this branch

I'll respond when I notice you've made these changes