Skip to content

Commit

Permalink
Create GitHub Action for FlowCrafter
Browse files Browse the repository at this point in the history
FlowCrafter can now be run automatically as a GitHub Action. When it
detects changes to the workflows, it automatically creates a pull
request to update them.
  • Loading branch information
jdno committed Dec 21, 2023
1 parent 910c21c commit 9b49938
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/flowcrafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: FlowCrafter

"on":
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update:
name: Update
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run FlowCrafter
uses: ./
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rules:
line-length:
ignore: |
.github/workflows/*
action.yml
45 changes: 45 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: FlowCrafter
description: Run FlowCrafter and update the GitHub Actions

runs:
using: "composite"
steps:
- name: Install FlowCrafter
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/jdno/flowcrafter/releases/download/v0.3.0/flowcrafter-installer.sh | sh"

- name: Print FlowCrafter version
shell: bash
run: 'echo "Using FlowCrafter v$(flowcrafter --version)"'

- name: Checkout code
uses: actions/checkout@v4

- name: flowcrafter update
shell: bash
run: "flowcrafter update"

- name: Check if workflows changed
id: check
shell: bash
run: |
if git diff --cached --exit-code --quiet; then
echo 'No changes detected'
echo "changed=false" >> $GITHUB_OUTPUT
else
echo 'Changes detected'
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Create pull request
uses: peter-evans/create-pull-request@v5
if: steps.check.outputs.changed == 'true' && github.event_name != 'push' && github.event_name != 'pull_request'
with:
add-paths: ".github/workflows"
branch: "flowcrafter/update"
commit-message: "Update GitHub Actions"
title: "Update GitHub Actions"
body: |
This pull request was automatically created by FlowCrafter after
running `flowcrafter update` on the repository.

0 comments on commit 9b49938

Please sign in to comment.