Skip to content

Commit

Permalink
Add automation code
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefishy committed Nov 1, 2023
1 parent 5e67d58 commit 24a9a78
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
indent_size = 2
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
27 changes: 27 additions & 0 deletions .github/workflows/update-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Update Issues

on:
issues:
types: [opened, reopened, closed, labeled, unlabeled]
workflow_dispatch:

permissions:
contents: write
issues: read

jobs:
updater:
name: Update Issues
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true
- name: Run updater
run: bundle exec ruby bin/update-issues
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "git", "~> 1.18.0"
gem "octokit", "~> 8.0.0"
33 changes: 33 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.1.1)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
git (1.18.0)
addressable (~> 2.8)
rchardet (~> 1.8)
octokit (8.0.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
public_suffix (5.0.3)
rchardet (1.8.0)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)

PLATFORMS
arm64-darwin-23

DEPENDENCIES
git (~> 1.18.0)
octokit (~> 8.0.0)

BUNDLED WITH
2.4.21
36 changes: 36 additions & 0 deletions bin/update-issues
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/ruby

require "git"
require "octokit"
require "csv"

gitdir = Dir.pwd

git = Git.open(gitdir)

git.config("user.name", "Tile-Attribution Updater")
git.config("user.email", "[email protected]")

# GitHub repository in the format "owner/repo"
repo = ENV["GITHUB_REPOSITORY"]
branch = ENV["GITHUB_REF_NAME"]

client = Octokit::Client.new(:bearer_token => ENV["GITHUB_TOKEN"])
client.auto_paginate = true
issues = client.issues(repo, state: "open", labels: "accepted")

CSV.open("tile-attribution.csv", "w") do |csv|
csv << ["title", "number", "date"]
issues.each do |issue|
csv << [issue.title, issue.number, issue.closed_at]
end
end

puts "Add tile-attribution.csv to git"
git.add("tile-attribution.csv")

puts "Commit changes to #{branch}..."
git.commit("Update tile-attribution.csv")

puts "Push branch #{branch}..."
git.push("origin", branch)

0 comments on commit 24a9a78

Please sign in to comment.