Skip to content

Create Banner on Dispatch #3

Create Banner on Dispatch

Create Banner on Dispatch #3

Workflow file for this run

name: Create Banner PR
on:
workflow_dispatch:
inputs:
date:
description: 'Event Date (YYYY-MM-DD)'
required: true
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Configure git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Create new branch
run: git checkout -b banner-${{ github.event.inputs.date }}
- name: Create banner
run: |
npm i tsx -g
cd ./packages/image-generator
npm i
cd ../..
tsx --tsconfig ./packages/image-generator/tsconfig.json ./packages/image-generator/cli.ts --image event --date ${{ github.event.inputs.date }} > ./public/banners/${{ github.event.inputs.date }}.png
- name: Commit files
run: |
git add .
git commit -m "Add event banner for ${{ github.event.inputs.date }}"
- name: Push changes
run: git push origin event-${{ github.event.inputs.date }}
- name: Create PR
uses: actions/github-script@v6
with:
script: |
const date = "${{ github.event.inputs.date }}";
const headBranch = `banner-${date}`;
const baseBranch = 'main'; // Ensure this matches your repo's default branch
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Generated event banner for ${date}`,
head: headBranch,
base: baseBranch,
body: 'This PR adds new event banner.',
});