Skip to content

Commit

Permalink
Update Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
miketrethewey committed May 12, 2024
1 parent fb7b24a commit 62d42e0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 29 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on: [push, pull_request, workflow_call, workflow_dispatch]
# actions #
###########
# actions/checkout@v3.3.0
# actions/download-artifact@v3.0.2
# actions/setup-python@v4.5.0
# actions/upload-artifact@v3.1.2
# actions/download-artifact@v4.1.7
# actions/setup-python@v5.1.0
# actions/upload-artifact@v4.3.3

# stuff to do
jobs:
Expand All @@ -30,10 +30,10 @@ jobs:
steps:
# checkout commit
- name: ✔️Checkout commit
uses: actions/checkout@v3.5.0
uses: actions/checkout@v4.1.4
# install python
- name: 💿Install Python
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
python ./resources/ci/common/cleanup.py
# upload pages artifact for later step
- name: 🔼Upload Pages Artifact
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4.3.3
with:
name: pages-${{ matrix.os-name }}
path: ./
Expand All @@ -86,12 +86,12 @@ jobs:
steps:
# checkout gh-pages
- name: ✔️Checkout commit
uses: actions/checkout@v3.5.0
uses: actions/checkout@v4.1.4
with:
ref: gh-pages
# download pages artifact
- name: 🔽Download Pages Artifact
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v4.1.7
with:
name: pages-${{ matrix.os-name }}
path: ./
Expand Down
75 changes: 54 additions & 21 deletions resources/ci/common/list_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import ssl
import urllib.request
import yaml
from json.decoder import JSONDecodeError

allACTIONS = {}
listACTIONS = []

VER_WIDTH = 10
NAME_WIDTH = 40
LINE_WIDTH = 1 + NAME_WIDTH + 5 + VER_WIDTH + 5 + VER_WIDTH + 1

def process_walk(key, node):
'''
Expand Down Expand Up @@ -53,17 +57,25 @@ def walk(key, node):
for r, d, f in os.walk(os.path.join(".", ".github")):
if "actions" in r or "workflows" in r:
for filename in f:
# if it's not a YAML or it's turned off, skip it
if (".yml" not in filename and ".yaml" not in filename) or (".off" in filename):
continue
listACTIONS = []
# print filename
filename_line = "-" * (len(os.path.join(r, filename)) + 2)
print(
" " +
("-" * (len(os.path.join(r, filename)) + 2)) +
filename_line +
" "
)
print("| " + os.path.join(r, filename) + " |")
# read the file
with(open(os.path.join(r, filename), "r", encoding="utf-8")) as yamlFile:
print(
" " +
("-" * (40 + 5 + 10 + 2)) +
"|" +
filename_line +
"-" +
("-" * (LINE_WIDTH - len(filename_line) + 1)) +
" "
)
yml = yaml.safe_load(yamlFile)
Expand All @@ -73,6 +85,7 @@ def walk(key, node):
action = k.split('@')[0]
version = k.split('@')[1] if '@' in k else ""
latest = ""
# if it's not a location action, get the latest version number
if "./." not in action:
apiURL = f"https://api.github.com/repos/{action}/releases/latest"
if True:
Expand All @@ -86,44 +99,58 @@ def walk(key, node):
if e.code != 403:
print(e.code, apiURL)
if apiReq:
apiRes = json.loads(
apiReq.read().decode("utf-8"))
apiRes = {}
try:
apiRes = json.loads(
apiReq.read().decode("utf-8"))
except JSONDecodeError as e:
raise ValueError("🔴API Request failed: " + apiURL)
if apiRes:
latest = apiRes["tag_name"] if "tag_name" in apiRes else ""
if latest != "":
allACTIONS[action]["latest"] = latest
dictACTIONS[action] = version
# print action name and version info
for action, version in dictACTIONS.items():
print(
"| " + \
f"{action.ljust(40)}" + \
"\t " + \
f"{(version or 'N/A').ljust(10)}" + \
f"{action.ljust(NAME_WIDTH)}" + \
"\t" + \
f"{(version or 'N/A').ljust(VER_WIDTH)}" + \
"\t" + \
f"{allACTIONS[action]['latest']}" + \
f"{(allACTIONS[action]['latest'] or 'N/A').ljust(VER_WIDTH)}" + \
" |"
)
print(
" " +
("-" * (40 + 5 + 10 + 2)) +
("-" * (LINE_WIDTH + 2)) +
" "
)
print("")

print(
" " +
("-" * (len("| Outdated |") - 2)) +
" "
)
print("| Outdated |")
print(
" " +
("-" * (len("| Outdated |") - 2)) +
" "
)
# print outdated versions summary
first = True
outdated = False
for action, actionData in allACTIONS.items():
if len(actionData["versions"]) > 0:
if actionData["latest"] != "" and actionData["versions"][0] != actionData["latest"]:
outdated = True
if first:
first = False
filename_line = "-" * (len("| Outdated |"))
print(
" " +
filename_line +
" "
)
print("| 🔴Outdated |")
print(
"|" +
filename_line +
"-" +
("-" * (LINE_WIDTH - len(filename_line) + 1)) +
" "
)
print(
"| " + \
f"{action.ljust(40)}" + \
Expand All @@ -133,3 +160,9 @@ def walk(key, node):
f"{actionData['latest'].ljust(10)}" + \
" |"
)
if outdated:
print(
" " +
("-" * (LINE_WIDTH + 2)) +
" "
)

0 comments on commit 62d42e0

Please sign in to comment.