-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from GsLogiMaker:fix/filter-dev-only-files-fro…
…m-nightly Filter dev only files in nightly update process
- Loading branch information
Showing
2 changed files
with
82 additions
and
20 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 |
---|---|---|
|
@@ -303,26 +303,8 @@ jobs: | |
# # An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms | ||
# enableCrossOsArchive: true | ||
|
||
- name: 🌙 Clone nightly branch | ||
run: | | ||
git clone https://github.com/${{ github.repository }} ../nightly_tmp -b nightly | ||
mkdir ../nightly | ||
mkdir ../nightly/.git | ||
cp -r ../nightly_tmp/.git/* ../nightly/.git/ | ||
- name: 🖨️ Copy dev branch plugin to nightly | ||
run: | | ||
cp --recursive --force ./* ../nightly/ | ||
- name: ➕ Add and commit to nightly | ||
id: add-and-commit | ||
continue-on-error: true | ||
run: | | ||
cd ../nightly | ||
git config --global user.name github-actions[bot] | ||
git config --global user.email [email protected] | ||
git add . | ||
git commit --all -m "(AUTO) ${{ github.event.head_commit.message }}" | ||
- name: 🌙 Update nightly | ||
run: python utils/update_nightly.py --repository ${{ github.repository }} | ||
|
||
- name: 📤 Push to nightly | ||
uses: ad-m/github-push-action@master | ||
|
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,80 @@ | ||
|
||
import argparse | ||
import shutil | ||
import subprocess | ||
import fnmatch | ||
import os | ||
|
||
nightly_ignores = [ | ||
"./cpp/*", | ||
"./.git/*", | ||
"./.github/*", | ||
"./.vscode/*", | ||
"./unittests/*", | ||
"./utils/*", | ||
"./.gitmodules", | ||
"./.gitignore", | ||
] | ||
|
||
def main() -> None: | ||
p = argparse.ArgumentParser( | ||
prog='UpdateNightly', | ||
description='Updates the nightly branch of Glecs from the dev branch.', | ||
) | ||
p.add_argument( | ||
"--repository", | ||
type=str, | ||
required=True, | ||
help="The owner and name of the repository. (Ex. GsLogiMaker/glecs_godot_plugin)", | ||
) | ||
|
||
args = p.parse_args() | ||
|
||
os.mkdir("../nightly") | ||
clone_nightly(args.repository) | ||
copy_dev_plugin_to_nightly() | ||
|
||
def clone_nightly(repo:str) -> None: | ||
subprocess.run(["git", "clone", f"https://github.com/{repo}", f"../nightly_tmp", "-b", "nightly"]) | ||
subprocess.run(["cp", "-r", f"../nightly_tmp/.git/", f"../nightly/.git/"]) | ||
|
||
def copy_dev_plugin_to_nightly() -> None: | ||
# Get all paths | ||
walker = os.walk("./") | ||
paths:list[str] = [] | ||
for item in walker: | ||
for folder in item[1]: | ||
paths.append(os.path.join(item[0], folder) + "/") | ||
for file in item[2]: | ||
paths.append(os.path.join(item[0], file)) | ||
|
||
# Filter paths to copy | ||
filtered_paths = list((n for n in paths | ||
if not any( | ||
fnmatch.fnmatch(n, ignore) for ignore in nightly_ignores | ||
) | ||
)) | ||
|
||
# Create directories | ||
for path in filtered_paths: | ||
if not path.endswith("/"): | ||
continue | ||
os.mkdir(os.path.join("../nightly/", path)) | ||
|
||
# Copy files | ||
for path in filtered_paths: | ||
if path.endswith("/"): | ||
continue | ||
shutil.copy(path, os.path.join("../nightly/", path)) | ||
|
||
def commit_to_nightly() -> None: | ||
cwd = os.getcwd() | ||
subprocess.run(["cd", "../nightly"]) | ||
subprocess.run(["git", "config", "--global", "user.name", "github-actions[bot]"]) | ||
subprocess.run(["git", "config", "--global", "user.email", "[email protected]"]) | ||
subprocess.run(["git", "commit", "--all", "-m", "(AUTO) ${{ github.event.head_commit.message }}"]) | ||
subprocess.run(["cd", cwd]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |