-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Am K
committed
Jul 25, 2023
1 parent
3c7eb35
commit c00c949
Showing
7 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python | ||
|
||
|
||
COPY entrypoint /usr/local/bin/entrypoint | ||
ENTRYPOINT ["/usr/local/bin/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: Action Build | ||
description: build holidays.json | ||
|
||
runs: | ||
using: docker | ||
image: Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
|
||
python build.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Workflow build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v1 | ||
- name: build | ||
uses: ./.github/action-build/ | ||
- name: commit changes | ||
uses: EndBug/add-and-commit@v4 | ||
with: | ||
message: "[Workflow] build" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#-*-coding:utf8;-*- | ||
import json | ||
from datetime import datetime | ||
|
||
# Informasi kredit tentang kode | ||
credit = { | ||
"updated": datetime.now().strftime("%Y%m%d %H:%I:%S"), | ||
"author": "guangrei", | ||
"link": "https://github.com/guangrei"} | ||
|
||
# Membaca konten dari file "calendar.json" dan menguraikannya menjadi bentuk dictionary Python | ||
with open("calendar.json", "r") as f: | ||
js = json.loads(f.read()) | ||
|
||
# Menghapus kunci "info" dari dictionary "js" | ||
del js["info"] | ||
out = {} | ||
|
||
|
||
def get_holiday(des, sum): | ||
""" | ||
Fungsi untuk mendapatkan hari libur dari deskripsi dan ringkasan yang diberikan. | ||
Parameters: | ||
des (list): Daftar deskripsi yang berisi kata "libur" atau tidak. | ||
sum (list): Daftar ringkasan hari yang sesuai dengan deskripsi. | ||
Returns: | ||
str: Ringkasan hari libur jika ditemukan, jika tidak kembali None. | ||
""" | ||
i = 0 | ||
for cek in des: | ||
if "libur" in cek.lower(): | ||
return sum[i] | ||
else: | ||
i = i + 1 | ||
|
||
|
||
# Iterasi melalui setiap kunci dan nilai dalam dictionary "js" | ||
for k, v in js.items(): | ||
if v["holiday"]: | ||
out[k] = {} | ||
# Mendapatkan ringkasan hari libur menggunakan fungsi get_holiday | ||
out[k]["summary"] = get_holiday(v["description"], v["summary"]) | ||
|
||
# Menambahkan informasi kredit ke dictionary "out" | ||
out["info"] = credit | ||
|
||
# Mengkonversi dictionary "out" menjadi format JSON dan menyimpannya di file "holidays.json" | ||
s = json.dumps(out, sort_keys=True) | ||
with open("holidays.json", "w") as f: | ||
f.write(s) |