Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,269
Community Members
 
Community Events
165
Community Groups

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

1 comment

Thanks Pramodh for the article. 

Like Pramodh M likes this

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you