Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

GitHub Script with GitHub Actions Automating Workflows

Hello folks,

This is a series of articles where I explain GitHub Script with GitHub Actions and how you can automate publishing data on Atlassian & GitHub Platform based on the results of Workflow.

For example, let us have look at sample workflow.

If the Build is successful, github-actions bot will comment success and if fails it will comment failure.

YAML File under .github/workflows directory in GitHub Repository

name: CI Workflow

on:
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
         uses: actions/checkout@v2

     - name: Get Pull Request ID
        run: |
          export PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
          echo "pr_num=$PR_NUMBER" >> $GITHUB_ENV

     - name: Add Comment to Pull Request if Success
        if: ${{ success() }}
        uses: actions/github-script@v5
        with:
          script: |
            await github.rest.issues.createComment({
            owner: context.repo.owner,
            repo: context.repo.repo,
            issue_number: ${{ env.pr_num }},
            body: 'Its Success'
            });

     - name: Add Comment to Pull Request if Failure
        if: ${{ failure() }}
        uses: actions/github-script@v5
        with:
        script: |
          await github.rest.issues.createComment({
          owner: context.repo.owner,
          repo: context.repo.repo,
          issue_number: ${{ env.pr_num }},
          body: 'Its Failure'
          });

This example will get you started with Automations that can be carried out with GitHub Actions and Jira Platform for seamless integration between the applications.

Please follow the link here to know about verified actions available in GitHub Marketplace from Atlassian.

Thanks,
Pramodh

TAGS
AUG Leaders

Atlassian Community Events