Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
64bfc10
Wrote some stuff I should've done a hot minute ago
HarrierPigeon Sep 8, 2022
63725e4
trying to get out of relative path?
HarrierPigeon Sep 8, 2022
0e0921e
oops
HarrierPigeon Sep 8, 2022
d2e5b4c
second time I've named it the wrong thing...
HarrierPigeon Sep 8, 2022
ea85f3f
Update reusable.yml
HarrierPigeon Sep 8, 2022
0d60609
Update and rename rename-gitinfo.py to renamegitinfo.py
HarrierPigeon Sep 8, 2022
05ab4f1
Update add-config.py
HarrierPigeon Sep 8, 2022
fb2ccc5
Update reusable.yml
HarrierPigeon Sep 8, 2022
431e938
Update add-config.py
HarrierPigeon Sep 8, 2022
e38677c
un-recommented thingies.
HarrierPigeon Sep 9, 2022
d7e9d91
re-added renamegitinfo
HarrierPigeon Sep 9, 2022
49a2539
added step, going to try this agaiiiin
HarrierPigeon Sep 10, 2022
44bcc4c
poosh
HarrierPigeon Sep 10, 2022
8ab425a
more problems?
HarrierPigeon Sep 10, 2022
cc304ac
Update reusable.yml
HarrierPigeon Sep 10, 2022
c034090
trying things- added conditionals
HarrierPigeon Sep 11, 2022
9126360
oopdate
HarrierPigeon Sep 11, 2022
d0b8668
y33t
HarrierPigeon Sep 11, 2022
b68a815
I did the same thingy twice. Oops.
HarrierPigeon Sep 11, 2022
1cab77b
debugging the clasp-runner
HarrierPigeon Sep 11, 2022
ac2e97c
renamed file
HarrierPigeon Sep 11, 2022
df41bac
converted stdout from class Bytes to class String
HarrierPigeon Sep 11, 2022
db10600
About to get even fancier. Switched to utf-16.
HarrierPigeon Sep 11, 2022
214f119
didn't like utf-16...
HarrierPigeon Sep 11, 2022
93ed49e
even cleaner.
HarrierPigeon Sep 11, 2022
9932fd7
Getting MVP demo setup.
HarrierPigeon Sep 11, 2022
029df25
Fixed OOP
HarrierPigeon Sep 11, 2022
952f2b7
O/I => I/O
HarrierPigeon Sep 11, 2022
6969480
added WYLO
HarrierPigeon Sep 11, 2022
eb35be2
added some stuff, everything should "just work" I think...
HarrierPigeon Sep 12, 2022
a681d59
added .
HarrierPigeon Sep 12, 2022
d09dc5c
Prep for push to main
HarrierPigeon Sep 14, 2022
1b04946
Final prep for main release
HarrierPigeon Sep 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ jobs:

- name: Pull Script Tooling
id: pull-python-script
if: ${{github.event_name != 'schedule' }}
uses: actions/checkout@v3
with:
repository: texas-mcallen-mission/deploy-google-app-script-action-typescript
path: deploy-data
ref: 'main'

- name: Set up things to make it easier to transition over.
id: repo-setup
if: ${{ github.event_name != 'schedule'}}
run: /bin/python3 deploy-data/scripts/pre-setup.py

- name: Set scriptId in .clasp.json file
id: set-script-id
Expand Down Expand Up @@ -142,10 +149,17 @@ jobs:
env:
CONFIG_DATA: ${{ secrets.IN_CONFIG_DATA }}
# 🐧

- name: rename git-info and give it an A
id: rename-git-info-in-python
if: ${{github.event_name != 'schedule' }}
run: /bin/python3 deploy-data/scripts/rename-git-info.py "testArg"

# updated in fixes-and-updates branch to catch errors.
- name: Push script to scripts.google.com
id: clasp-push
if: ${{ github.event_name != 'schedule' }}
run: clasp push -f
run: /bin/python3 deploy-data/scripts/run-clasp-fancy.py

- name: Deploy Script
id: clasp-deploy
Expand Down
7 changes: 7 additions & 0 deletions required-files/.clasp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"scriptId": "SCRIPT_ID",
"rootDir": "./",
"parentId": [
"PARENT_ID"
]
}
1 change: 1 addition & 0 deletions required-files/.claspignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deploy-data/**
7 changes: 7 additions & 0 deletions required-files/appsscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"timeZone": "America/New_York",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
2 changes: 2 additions & 0 deletions git-info.js → required-files/git-info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// the contents of this file get find-replaced using sed at action runtime- please be careful in here!
// Hey, you should consider making a permanent copy of this and deleting this line!

const GITHUB_DATA = {
commit_sha:"COMMITSHA", // done
action_event_name: "EVENTNAME", // done
Expand Down
14 changes: 14 additions & 0 deletions required-files/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": ["ESNext"],
"target": "ES6",
"types": [
"google-apps-script"
],
"outDir": "./ts",
"rootDir": "./"

}
}
3 changes: 2 additions & 1 deletion scripts/add-config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import os

nameOfScript = sys.argv[0]
commandLineArgs = sys.argv[1]
Expand All @@ -7,7 +8,7 @@

numArgs = len(sys.argv)

print(nameOfScript," arguments: ",numArgs)
print(nameOfScript," arguments: ",numArgs,"running with rename script internally.")


file_in = open("git-info.js", "rt")
Expand Down
44 changes: 44 additions & 0 deletions scripts/pre-setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import shutil
print("setting things up.")

# Things to check for:
# Does clasp.json exist yet?
# Does git-info.js (or TS?) exist yet? - if not, copy over local version
# Does .claspignore exist yet? - if not, create a file, and put /deploy-data in it
# - also just pipe in deploy-data/ in there, it really doesn't matter if it's there twice
# Could also stick an empty .gs file in there as a watermark, lol?
# Basically I need to find *everything* necessary to make an empty repo and push it and make a local, basic copy.

claspIg = ".claspignore"
deployDataLine = "deploy-data/**"

files = [".clasp.json", "git-info.js", "tsconfig.json", "appsscript.json", claspIg]

addedFiles = []


reqFileDir = "deploy-data/required-files/"

for entry in files:
if os.path.exists(entry) == False and os.path.exists(reqFileDir+entry) == True:
shutil.copy2(reqFileDir+entry, entry)
addedFiles.append(entry)


# then run code to modify claspignore?
if addedFiles.count(claspIg) == 0: # this is like array.includes, I guess?
# pipe thingies in
print("modifying"+claspIg)
claspIgnoreFile = open(claspIg, mode="r+")
print("pre-mod:", claspIgnoreFile.read())
print(deployDataLine, file=claspIgnoreFile) # adds newline
claspIgnoreFile.close()


if len(addedFiles) > 0:
# spread operator thingy to get rid of the brackets. Super neat!
print("Completed- added ", *addedFiles)
else:
print("Completeted, no new files added.")

11 changes: 11 additions & 0 deletions scripts/rename-git-info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
import glob

print(glob.glob(os.getcwd()))

input_source = "git-info.js"
print("current working directory:",os.getcwd())
output_dest = "aaa-git-info.js"
print("renaming")
os.rename(input_source,output_dest)
print("finished")
44 changes: 44 additions & 0 deletions scripts/run-clasp-fancy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import subprocess

# The new-and-improved CLASP runner!
# This bad boi checks the output of CLASP and makes sure that it doesn't throw an error.
# Previously, if clasp didn't succeed, it'd just continue on without any indication of problems.
# Now, it'll throw an error and spit out the logs if it breaks. *WAY* better. :)
#

# custom exception type
class killAction(Exception):
pass

# the thing that runs clasp pushing itself
result = subprocess.run(["clasp","push","-f"],stdout=subprocess.PIPE)

# the rest of this parses the output from CLASP.

# wrote this as a function so that I could write tests for it
def wasSuccessful(data):

returnVal = True

gaxios = "GaxiosError:"
pushFailure = "Push failed. Errors:"
gaxiosFail = (gaxios in data) # true if GaxiosError: is in the log
pushFail = (pushFailure in data) # true if Push Failure is in the log
if gaxiosFail or pushFail:
returnVal = False
return returnVal

encoding = 'utf-8'
parsedResult = str(result.stdout,encoding)
claspRun = wasSuccessful(parsedResult)

# *might* add some extra parsing here to make the result easier to read?

print(parsedResult)
if claspRun == False:
# and then throw an error.
raise killAction("""
Clasp had an internal error!""")
else:
print("""
Push succeeded.""")