Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to use Green Scraper om GitHub reusable workflow #7

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/generate-event-list-with-green-scraper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Green Scraper event list generation

on:
workflow_dispatch:
push:
branches:
- main
paths:
- '.github/workflows/green-talks-scraper.yml'
- '.github/workflows/generate-event-list-with-green-scraper.yml'
- 'green-talks-scraper/*'
- '!green-talks-scraper/README.md'
pull_request:
paths:
- '.github/workflows/green-talks-scraper.yml'
- '.github/workflows/generate-event-list-with-green-scraper.yml'
- 'green-talks-scraper/*'
- '!green-talks-scraper/README.md'

jobs:
call-green-scraper-workflow:
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/green-talks-scraper.yml
with:
output-path: 'green-talks-scraper/talks.md'
repository: 'cncf-tags/tag-env-tooling'
secrets:
token: ${{ secrets.GREENSCRAPER_WORKFLOW_TOKEN }}
40 changes: 22 additions & 18 deletions .github/workflows/green-talks-scraper.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Green Talks Scraper

on:
push:
branches:
- main
paths:
- '.github/workflows/green-talks-scraper.yml'
- 'green-talks-scraper/*'
- '!green-talks-scraper/README.md'
workflow_call:
inputs:
output-path:
required: true
type: string
repository:
required: true
type: string
secrets:
token:
required: true

jobs:
scrape:
Expand All @@ -19,29 +23,29 @@ jobs:
with:
persist-credentials: false

- name: Prepend line to talks.md
run: echo "### An automatically generated list of environmental sustainability-related talks at The Linux Foundation events" > green-talks-scraper/talks.md
- name: Prepend line to the output file
run: echo "### An automatically generated list of environmental sustainability-related talks at The Linux Foundation events" > ${{ inputs.output-path }}

- name: Run Scraper Script
- name: Run Green Scraper tool
run: |
chmod +x green-talks-scraper/scraper.sh
./green-talks-scraper/scraper.sh >> green-talks-scraper/talks.md
./green-talks-scraper/scraper.sh >> ${{ inputs.output-path }}

- name: Commit file
- name: Create pull request with updated event list
run: |
# Check if "talks.md" has been modified
if git diff --name-only | grep "talks.md" || git ls-files --others --exclude-standard | grep "talks.md"; then
# Check if ${{ inputs.output-path }} has been modified
if git diff --name-only | grep ${{ inputs.output-path }} || git ls-files --others --exclude-standard | grep ${{ inputs.output-path }}; then
BRANCH_NAME="update-talks-$(date +'%Y%m%d%H%M')"
git config --local user.email "workflow@green-talks-scraper.com"
git config --local user.name "green-talks-scraper-workflow"
git checkout -b $BRANCH_NAME
git add green-talks-scraper/talks.md
git commit -m "Update the green talks list [skip actions]"
git remote set-url origin https://${GH_TOKEN}@github.com/cncf-tags/tag-env-tooling.git
git add ${{ inputs.output-path }}
git commit -s -m "docs: update event list with Green Scraper [skip actions]"
git remote set-url origin https://${{ secrets.token }}@github.com/${{ inputs.repository }}.git
git push --set-upstream origin $BRANCH_NAME -f
gh pr create --base main --head $BRANCH_NAME --title "Update the list of talks" --body "Update the list of talks"
else
echo "The list of talks is up to date"
fi
env:
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.token }}
3 changes: 2 additions & 1 deletion green-talks-scraper/talks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Overview of sustainability-related events
description: This list provides overview of events that include content related to cloud native environmental sustainability. The list is auto-generated and continuously updated by Green Scraper tool.
---
---

Loading