Code Monkey home page Code Monkey logo

Comments (4)

github-actions avatar github-actions commented on June 17, 2024

🎉 You've created this issue comment using GitHub Script!!!

from write-github-script.

github-learning-lab avatar github-learning-lab commented on June 17, 2024

Let's improve the workflow

@kirillperesh it looks like you workflow has completed! Let's take a look at the results!

We should be pretty familiar with the first portion of the workflow, it's the same as the first time it ran, and it just creates a comment whenever a new issue has been created.

The second portion may exactly be clear to you, but this issue was added to a project board that is present in this repository. Checkout the projects tab if you want to see that this issue has been added!

Multiple steps

One benefit of using actions is the ability to separate jobs into smaller units of work called steps. If we think about what our workflow is doing we can see that it makes more sense to have these two tasks take place across two steps.

As an added advantage, once we break the current workflow into multiple steps we can apply logic through expressions to them. This will let us create rules around when steps are allowed to run. Ultimately this allows us to optimize our workflow run!

Since GitHub Script is simply an action, breaking each unique task into a new step works just fine! We will do this in our next activity!

from write-github-script.

github-learning-lab avatar github-learning-lab commented on June 17, 2024

Add steps for each action

We will make the following changes to the current workflow file:

  • Name each step so we can easily keep track of it in the actions tab
  • Use expressions to determine if a step should execute

⌨️ Activity: Add newly opened issue to project board

  1. Edit the current workflow .github/workflows/my-workflow.yml to have the following contents:

    name: Learning GitHub Script
    
    on:
      issues:
        types: [opened]
    
    jobs:
      comment:
        runs-on: ubuntu-latest
        steps:
        - name: Comment on new issue
          uses: actions/[email protected]
          with:
            github-token: ${{secrets.GITHUB_TOKEN}}
            script: |
                github.issues.createComment({
                issue_number: context.issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: "🎉 You've created this issue comment using GitHub Script!!!"
                })
    
        - name: Add issue to project board
          if: contains(github.event.issue.labels.*.name, 'bug')
          uses: actions/[email protected]
          with:
            github-token: ${{secrets.GITHUB_TOKEN}}
            script: |
                github.projects.createCard({
                column_id: 12524419,
                content_id: context.payload.issue.id,
                content_type: "Issue"
                });
    
  2. Commit the workflow to a new branch.

  3. Create a pull request, I suggest the title Create better comments.

  4. Supply the pull request body content and click Create pull request.


I am waiting for you to create a new pull request before moving on.

I'll respond in the pull request you create

from write-github-script.

github-learning-lab avatar github-learning-lab commented on June 17, 2024

A new pull request

I have created a new pull request where we will continue this lesson. Click the link to meet me over there.

from write-github-script.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.