-
Notifications
You must be signed in to change notification settings - Fork 61
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 #48 from McCloudS/launcher
Launcher
- Loading branch information
Showing
3 changed files
with
42 additions
and
57 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Build_Subgen_Dockerfile | |
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'launcher' | ||
paths-ignore: | ||
- '**.md' | ||
- '**.yml' | ||
|
@@ -13,67 +13,15 @@ jobs: | |
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Check disk space | ||
run: df . -h | ||
- | ||
name: Free disk space | ||
run: | | ||
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true | ||
sudo rm -rf \ | ||
/usr/share/dotnet /usr/local/lib/android /opt/ghc \ | ||
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ | ||
/usr/lib/jvm || true | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf "/usr/local/share/boost" | ||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
echo "some directories deleted" | ||
sudo apt install aptitude -y >/dev/null 2>&1 | ||
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \ | ||
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \ | ||
google-cloud-sdk imagemagick \ | ||
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \ | ||
mercurial apt-transport-https mono-complete libmysqlclient \ | ||
unixodbc-dev yarn chrpath libssl-dev libxft-dev \ | ||
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \ | ||
snmp pollinate libpq-dev postgresql-client powershell ruby-full \ | ||
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \ | ||
-y -f >/dev/null 2>&1 | ||
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1 | ||
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | ||
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | ||
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1 | ||
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1 | ||
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1 | ||
sudo apt-get autoremove -y >/dev/null 2>&1 | ||
sudo apt-get autoclean -y >/dev/null 2>&1 | ||
echo "some packages purged" | ||
- | ||
name: Check disk space | ||
run: | | ||
df . -h | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Log in to the Github Container registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@v3 | ||
- uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Build | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
tags: mccloud/subgen:latest | ||
tags: mccloud/subgen:launcher |
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,37 @@ | ||
import os | ||
import requests | ||
|
||
def convert_to_bool(in_bool): | ||
if isinstance(in_bool, bool): | ||
return in_bool | ||
else: | ||
value = str(in_bool).lower() | ||
return value not in ('false', 'off', '0', 0) | ||
|
||
def download_from_github(url, output_file): | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
with open(output_file, 'wb') as f: | ||
f.write(response.content) | ||
print(f"File downloaded successfully to {output_file}") | ||
else: | ||
print(f"Failed to download file from {url}") | ||
|
||
def main(): | ||
github_url = "https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py" | ||
output_file = "subgen.py" | ||
|
||
# Check if the environment variable is set | ||
github_download_enabled = convert_to_bool(os.getenv("UPDATE", False)) | ||
|
||
if not os.path.exists(output_file): | ||
print(f"File {output_file} does not exist. Downloading from GitHub...") | ||
download_from_github(github_url, output_file) | ||
elif github_download_enabled: | ||
print(f"File exists, but UPDATE is set to True. Downloading {output_file} from GitHub...") | ||
download_from_github(github_url, output_file) | ||
else: | ||
print("Environment variable UPDATE is not set or set to False, skipping download.") | ||
|
||
if __name__ == "__main__": | ||
main() |