Skip to content

Commit

Permalink
Attempt to deploy in github actions
Browse files Browse the repository at this point in the history
(like hell this is gonna work first time ...)
  • Loading branch information
calaldees committed Oct 18, 2024
1 parent 68d4e63 commit ebbe210
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy_website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: deploy_language_referemce

on:
push:
branches:
- master
paths:
- '.github/workflows/deploy_website.yml'
- 'teachprogramming/lib/**'
- 'teachprogramming/static/language_reference/**'

jobs:

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main

- name: compile_and_run_languages
run: (cd teachprogramming/static/language_reference && make build_and_run)

- name: build_static
run: (cd teachprogramming/lib && make build_static)

- name: scp_api
uses: appleboy/scp-action@master
with:
host: computingteachers.uk
username: computingteachers
key: ${{ secrets.DEPLOY_SSH_KEY }}
source: "teachprogramming/lib/api/v1"
strip_components: 3
target: "computingteachers.uk/api"

- name: scp_static
uses: appleboy/scp-action@master
with:
host: computingteachers.uk
username: computingteachers
key: ${{ secrets.DEPLOY_SSH_KEY }}
source: "teachprogramming/lib/static"
strip_components: 2
target: "computingteachers.uk"
9 changes: 5 additions & 4 deletions teachprogramming/lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
DOCKER_IMAGE:=site
DOCKER_RUN:=docker run -it --rm \
_DOCKER_RUN:=docker run --rm \
--workdir /app/ \
--volume ${PWD}:/app/ \
--volume ${PWD}/../static:/static/ \
--publish 8000:8000 \
--env PYTHONPATH=./ \
${DOCKER_IMAGE}
--env PYTHONPATH=./
DOCKER_RUN:=${_DOCKER_RUN} -it ${DOCKER_IMAGE}
DOCKER_RUN_no_tty:=${_DOCKER_RUN} ${DOCKER_IMAGE}

serve_static: build_static
open http://localhost:8000/static/
python3 -m http.server
build_static: build_docker
${DOCKER_RUN} python3 api.py /static/projects/ /static/language_reference/languages/ --export
${DOCKER_RUN_no_tty} python3 api.py /static/projects/ /static/language_reference/languages/ --export
build_and_upload: build_static
scp -r ./api/v1 computingteachers.uk:computingteachers.uk/api
scp -r ./static computingteachers.uk:computingteachers.uk
Expand Down
2 changes: 1 addition & 1 deletion teachprogramming/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _filter_file(f):
# Setup App -------------------------------------------------------------------

def create_wsgi_app(project_path=None, language_path=None, **kwargs):
app = falcon.API()
app = falcon.App()
app.add_route(r'/', IndexResource())
app.add_static_route(r'/static', str(Path('static').resolve()))
app.add_route(r'/api/v1/language_reference.json', LanguageReferenceResource(language_path))
Expand Down
2 changes: 1 addition & 1 deletion teachprogramming/static/language_reference/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PATH_LANGAUGES := languages
# Main -------------------------------------------------------------------------

build_and_run:
docker-compose up --build
docker compose up --build

assert_language_output:
python3 assert_language_output.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Workshop
* Write down the technical terms - consolidate as group
7. Look at `docker-compose.yml`
* Q: What is this file doing?
8. Run `docker-compose up`
8. Run `docker compose up`
* visit `:8001` `:8002` `:8003` `:8004`
* Look at the terminal log
* Q: What is `docker-compose`?
Expand Down

0 comments on commit ebbe210

Please sign in to comment.