Skip to content

Commit

Permalink
chore: Create a workflow to open pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
neriberto committed Apr 24, 2024
1 parent 70e672f commit 512a616
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 22 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
name: 🔨 Build Test
name: "Build Test"

on:
workflow_dispatch:
workflow_dispatch: null
push:
branches:
- develop
pull_request:
branches:
- main
- develop
- feature*
- feature/**
- hotfix/**
- bug/**
paths:
- '**.go'
- '**.mod'

jobs:
build:
name: Test Builds
runs-on: ${{ matrix.os }}
runs-on: '${{ matrix.os }}'
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macOS-12 ]
go-version: [ 1.21.x ]
os:
- ubuntu-latest
- windows-latest
- macOS-12
go-version:
- 1.21.x
steps:
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

go-version: '${{ matrix.go-version }}'
- name: Check out code
uses: actions/checkout@v3

uses: actions/checkout@v4
- name: Build
run: go build .
working-directory: cmd/hednsextractor/

- name: Test
run: go test ./...
working-directory: .

- name: Install
run: go install
working-directory: cmd/hednsextractor/

- name: Race Condition Tests
run: go build -race .
working-directory: cmd/hednsextractor/


2 changes: 1 addition & 1 deletion .github/workflows/dep-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
github-token: ${{ secrets.DEPENDABOT_PAT }}
target: all
target: all
34 changes: 34 additions & 0 deletions .github/workflows/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Open Pull Request on Develop

on:
push:
branches:
- feature/*

jobs:
open_pull_request:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Check if PR exists
id: check_pr
run: |
PR_EXIST=$(gh pr list --state open --base develop --head "$(echo "${GITHUB_REF}" | sed -E 's/refs\/heads\/feature\/(.*)/\1/')")
if [[ -z $PR_EXIST ]]; then
echo "::set-output name=pr_exists::false"
else
echo "::set-output name=pr_exists::true"
fi
env:
GH_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}

- name: Create PR
if: steps.check_pr.outputs.pr_exists == 'false'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.API_TOKEN_GITHUB }}
branch: develop
title: "Merge feature branch"
body: "This pull request merges the changes from the feature branch into develop."

0 comments on commit 512a616

Please sign in to comment.