Initial commit for workflow

This commit is contained in:
Nemo
2022-03-24 15:26:07 +05:30
parent c695f2c649
commit 6b082aac17
3 changed files with 81 additions and 0 deletions

13
.editorconfig Normal file
View File

@@ -0,0 +1,13 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://EditorConfig.org
root = true
; Use 2 spaces for indentation in all files
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
insert_final_newline = true

36
.github/workflows/update.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Update Data
on:
push:
schedule:
# “At minute 17 past hour 6 and 18.”
# https://crontab.guru/#17_6,18_*_*_*
- cron: '17 6,18 * * *'
jobs:
update:
name: Update data
runs-on: ubuntu-latest
steps:
- name: Cache Repositories
uses: actions/cache@v3
with:
path: ~/.cache
key: cache
- uses: actions/checkout@v3
name: Clone self repository
with:
ref: ${{ github.head_ref }}
- uses: actions/checkout@v3
name: Clone website
with:
repository: endoflife-date/endoflife.date
path: website
submodules: false
- name: Update Release data
run: |
mkdir -p ~/.cache/{npm,git,oci} releases/{npm,git,oci}
ruby update.rb website ~/.cache releases
- uses: stefanzweifel/git-auto-commit-action@v4
name: Commit and update new releases
with:
commit_message: Update Releases
commit_author: actions-user <65916846+actions-user@users.noreply.github.com>

32
update.rb Normal file
View File

@@ -0,0 +1,32 @@
require 'yaml'
require 'date'
WEBSITE_DIR=ARGV[0]
CACHE_DIR=ARGV[1]
OUTPUT_DIR=ARGV[2]
def update_git_releases(product, url)
pwd = Dir.pwd
repo_dir = "#{CACHE_DIR}/git/#{product}"
puts "Fetching #{url}"
unless Dir.exist? repo_dir
`git init --bare #{repo_dir}`
end
Dir.chdir repo_dir
`git config extensions.partialClone true`
`git fetch --auto-gc --auto-maintenance --progress --prune --prune-tags --quiet --tags --filter=blob:none "#{url}"`
Dir.chdir pwd
end
Dir.glob("#{WEBSITE_DIR}products/*.md").each do |product_file|
data = YAML.load_file product_file, permitted_classes: [Date]
data['auto'].each_entry do |ecosystem, url|
product = File.basename product_file, ".md"
case ecosystem
when 'git'
update_git_releases(product, url)
else
puts "No support for #{ecosystem} yet (#{url})"
end
end if data['auto']
end