Automated Pull Request #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI / Automated Pull Request | |
on: | |
push: | |
branches-ignore: | |
- "classic" | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */1 * * *' | |
jobs: | |
create_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Branch Info | |
id: branch-info | |
run: | | |
echo "BASE_REF=$(git symbolic-ref --short HEAD)" >> $GITHUB_ENV | |
echo "HEAD_REF=$(git symbolic-ref --short HEAD)" >> $GITHUB_ENV | |
- name: Create or Open A PR | |
id: create-pr | |
uses: repo-sync/pull-request@v2 | |
with: | |
github_token: ${{ secrets.BOT_TOKEN }} | |
destination_branch: "classic" | |
pr_title: "${{ github.workflow }} - (${{ github.event.head_commit.message }})" | |
pr_body: "Details are on their way... - says Hamster." | |
pr_reviewer: "offensive-vk" | |
pr_label: "bot,automated,hamster,pull-request" | |
pr_assignee: "TheHamsterBot" | |
pr_draft: false | |
continue-on-error: true | |
- name: Save PR Number in ENV | |
run: echo "PR_NUMBER=${{ steps.create-pr.outputs.pull-request-url }}" >> $GITHUB_ENV | |
update_pr: | |
needs: create_pr | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate Pull Request Template | |
run: | | |
timestamp=$(date '+%b %d, %A %I:%M:%S %p') | |
markdown=$(cat <<EOF | |
## This Pull Request Was Automated by [Hamster [bot]](https://github.com/TheHamsterBot) | |
> [!NOTE] | |
> Workflow Trigger: ${{ github.event_name }} event at ${{ env.HEAD_REF }} branch. | |
> Details of Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
- Author: @TheHamsterBot | |
- Branch: ${{ github.base_ref }} (base) / ${{ github.head_ref}} (head) | |
- Commit: ${{ github.sha }} | |
- Workflow Path: ${{ github.workflow }} | |
- Pull Request Number: #${{ github.event.pull_request.number || env.PR_NUMBER }} | |
- Pusher Details: ${{ github.event.commits.author.name }} <${{ github.event.commits.author.email }}> | |
--- | |
Thanks. | |
$timestamp | |
Your Hamster 🐹 <code>PR90XPOMFW68FM</code> | |
EOF) | |
echo "$markdown" > .github/Auto_Pull_Request.md | |
echo "MARKDOWN_CONTENT<<EOF" >> $GITHUB_ENV | |
echo "$markdown" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Update Pull Request Body | |
run: | | |
gh pr edit "$PR_NUMBER" --body "$MARKDOWN_CONTENT" | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
create_issue_on_success: | |
runs-on: ubuntu-latest | |
needs: create_pr | |
if: github.event_name != 'push' | |
steps: | |
- name: Create Issue using Bot | |
uses: dacbd/create-issue-action@main | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
title: | | |
${{ github.workflow }} - PR Created Successfully | |
assignees: TheHamsterBot | |
labels: automated,bot | |
body: | | |
## Pull Request Created Successfully: | |
- Author: @TheHamsterBot | |
- Branch: ${{ github.ref }} | |
- Commit: ${{ github.sha }} | |
- Workflow Path: ${{ github.workflow }} | |
- Branch: ${{ github.base_ref }} (base) / ${{ github.head_ref}} (head) | |
- Pull Request Number: #${{ env.PR_NUMBER || github.event.pull_request.number }} | |
create_issue_on_failure: | |
runs-on: ubuntu-latest | |
needs: create_pr | |
if: github.event_name != 'push' && failure() | |
steps: | |
- name: Create Failure Issue | |
uses: dacbd/create-issue-action@main | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
title: | | |
${{ github.workflow }} - PR Creation Failed | |
assignees: TheHamsterBot | |
labels: automated,bot | |
body: | | |
## Pull Request Creation Failed: | |
> [!WARNING] | |
> Workflow Trigger: ${{ github.event_name }} event at ${{ env.BASE_REF }} branch. | |
> Details of Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
- Author: @TheHamsterBot | |
- Branch: ${{ github.ref }} | |
- Commit: ${{ github.sha }} | |
- Workflow Path: ${{ github.workflow }} | |
- Error: ${{ job.status }} | |
# name: CI / Automated Pull Request | |
# on: | |
# push: | |
# branches-ignore: | |
# - "classic" | |
# workflow_dispatch: | |
# schedule: | |
# - cron: '0 */1 * * *' | |
# jobs: | |
# create_pr: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Get Branch Info | |
# id: branch-info | |
# run: | | |
# echo "BASE_REF=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
# echo "HEAD_REF=$(git rev-parse --abbrev-ref origin/HEAD)" >> $GITHUB_ENV | |
# - name: Create or Open A PR | |
# id: create-pr | |
# uses: repo-sync/pull-request@v2 | |
# with: | |
# github_token: ${{ secrets.BOT_TOKEN }} | |
# destination_branch: "classic" | |
# pr_title: "${{ github.workflow }} - (${{ github.event.head_commit.message }})" | |
# pr_body: "Details are on their way... - says Hamster." | |
# pr_reviewer: "offensive-vk" | |
# pr_label: "bot,automated,hamster,pull-request" | |
# pr_assignee: "TheHamsterBot" | |
# pr_draft: false | |
# - name: Save PR Number in ENV | |
# run: echo "PR_NUMBER=${{ steps.create-pr.outputs.number }}" >> $GITHUB_ENV | |
# update_pr: | |
# needs: create_pr | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Generate Pull Request Template | |
# run: | | |
# timestamp=$(date '+%b %d, %A %I:%M:%S %p') | |
# markdown=$(cat <<EOF | |
# ## This Pull Request Was Automated by [Hamster [bot]](https://github.com/TheHamsterBot) | |
# > [!NOTE] | |
# > Workflow Trigger: ${{ github.event_name }} event at ${{ env.HEAD_REF }} branch. | |
# > Details of Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
# - Author: @TheHamsterBot | |
# - Branch: ${{ env.BASE_REF }} (base) / ${{ env.HEAD_REF }} (head) | |
# - Commit: ${{ github.sha }} | |
# - Workflow Path: ${{ github.workflow }} | |
# - Pull Request Number: #${{ env.PR_NUMBER }} | |
# - Pusher Details: ${{ github.event.issue.user.id }} <${{ github.event.pusher.email }}> | |
# --- | |
# Thanks. | |
# $timestamp | |
# Your Hamster 🐹 <code>PR90XPOMFW68FM</code> | |
# EOF) | |
# echo "$markdown" > .github/Auto_Pull_Request.md | |
# echo "MARKDOWN_CONTENT<<EOF" >> $GITHUB_ENV | |
# echo "$markdown" >> $GITHUB_ENV | |
# echo "EOF" >> $GITHUB_ENV | |
# - name: Update Pull Request Body | |
# run: | | |
# gh pr edit "$PR_NUMBER" --body "$MARKDOWN_CONTENT" | |
# continue-on-error: true | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
# create_issue_on_success: | |
# runs-on: ubuntu-latest | |
# needs: create_pr | |
# if: success() | |
# steps: | |
# - name: Create Issue using Bot | |
# uses: dacbd/create-issue-action@main | |
# with: | |
# token: ${{ secrets.BOT_TOKEN }} | |
# title: | | |
# ${{ github.workflow }} - PR Created Successfully | |
# assignees: TheHamsterBot | |
# labels: automated,bot | |
# body: | | |
# ## Pull Requeste Created Successfully: | |
# - Author: @TheHamsterBot | |
# - PR URL: ${{ steps.open-pr.outputs.pull-request-url }} | |
# - Branch: ${{ github.ref }} | |
# - Commit: ${{ github.sha }} | |
# - Workflow Path: ${{ github.workflow_ref }} | |
# - Branch: ${{ github.base_ref }} (base) / ${{ github.head_ref }} (head) | |
# - Pull Request Number: #${{ github.event.number }} | |
# - Pull Request Title: ${{ github.event.pull_request.title }} | |
# create_issue_on_failure: | |
# runs-on: ubuntu-latest | |
# needs: create_pr | |
# if: failure() | |
# steps: | |
# - name: Create Failure Issue | |
# uses: dacbd/create-issue-action@main | |
# with: | |
# token: ${{ secrets.BOT_TOKEN }} | |
# title: | | |
# ${{ github.workflow }} - PR Creation Failed | |
# assignees: TheHamsterBot | |
# labels: automated,bot | |
# body: | | |
# ## Pull Request Creation Failed: | |
# > [!WARNING] | |
# > Workflow Trigger: ${{ github.event_name }} event at ${{ github.event.base_ref }} branch. | |
# > Details of Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
# - Author: @TheHamsterBot | |
# - Branch: ${{ github.ref }} | |
# - Commit: ${{ github.sha }} | |
# - Workflow Path: ${{ github.workflow_ref }} | |
# - Error: ${{ job.status }} |