GitHub Action that builds your Docker images and uploads your app to Tour de Cloud for the Tour de App competition.
-
Add a
TDC_TOKENsecret to your repository (how?). -
Add a
tourdeapp.yamlfile to the root of your repository, see Configuration. -
Create
.github/workflows/deploy.yml:name: Deploy to Tour de App on: push: branches: - main permissions: contents: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v7 - name: Upload to Tour de Cloud uses: studentscangrow/upload-app@v27 with: tdc_token: ${{ secrets.TDC_TOKEN }}
Every push to
mainbuilds and uploads your app. You can change the branch to any other.
Docker layers are cached in the GitHub Actions cache automatically, so repeated builds are faster.
| Input | Required | Default | Description |
|---|---|---|---|
tdc_token |
yes | Tour de Cloud team API token | |
api_url |
no | https://tourde.cloud/api/v2 |
Tour de Cloud API URL |
config_path |
no | tourdeapp.yaml |
Path to the configuration file |
debug |
no | false |
Log API requests and responses, see Debug logs |
| Output | Description |
|---|---|
upload_id |
Identifier of the upload |
images |
JSON array of the pushed images |
deployable |
true when the uploaded app can be deployed |
tourdeapp.yaml describes the containers of your app and how to build their images. The full specification is the JSON schema. Keep the first line of the example to get autocomplete in your editor.
# $schema: https://tourde.cloud/api/v2/schema
exposedPort: 80
containers:
- name: web
image: registry.tourde.cloud/<team-slug>/web
port: 80
- name: server
image: registry.tourde.cloud/<team-slug>/server
port: 8080
build:
- name: web
context: ./frontend
- name: server
context: ./backend
dockerfile: ./backend/docker/Dockerfile
args:
API_URL: https://example.com/apiEach item in build produces one image. context defaults to . and dockerfile defaults to Dockerfile inside the context. All paths are relative to the root of the repository, even when you use a different config_path.
Anywhere in tourdeapp.yaml you can write {{VARIABLE}} and the action replaces it with the value of the environment variable VARIABLE. Pass the variable to the step with env:
- name: Upload to Tour de Cloud
uses: studentscangrow/upload-app@v27
env:
API_KEY: ${{ secrets.API_KEY }}
with:
tdc_token: ${{ secrets.TDC_TOKEN }}build:
- name: web
context: ./frontend
args:
API_KEY: "{{API_KEY}}"If a variable is missing, the upload fails.
Set debug: true to print every request sent to Tour de Cloud and every response. The same logs also appear when you re-run a job with Enable debug logging. The configuration file is printed before substitution, so values of {{VARIABLE}} placeholders are not shown.
- name: Upload to Tour de Cloud
uses: studentscangrow/upload-app@v27
with:
tdc_token: ${{ secrets.TDC_TOKEN }}
debug: trueGitHub akce, která sestaví tvoje Docker obrazy a nahraje aplikaci do Tour de Cloud v rámci soutěže Tour de App.
-
V nastavení repozitáře vytvoř secret
TDC_TOKEN(jak?). -
Do kořenového adresáře repozitáře přidej soubor
tourdeapp.yaml, viz Konfigurace. -
Vytvoř soubor
.github/workflows/deploy.yml:name: Deploy to Tour de App on: push: branches: - main permissions: contents: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v7 - name: Upload to Tour de Cloud uses: studentscangrow/upload-app@v27 with: tdc_token: ${{ secrets.TDC_TOKEN }}
Každý push do větve
mainaplikaci sestaví a nahraje. Větev můžeš změnit na jakoukoli jinou.
Vrstvy Docker obrazů se automaticky ukládají do cache GitHub Actions, takže opakovaná sestavení jsou rychlejší.
| Vstup | Povinný | Výchozí hodnota | Popis |
|---|---|---|---|
tdc_token |
ano | API token týmu v Tour de Cloud | |
api_url |
ne | https://tourde.cloud/api/v2 |
URL API Tour de Cloud |
config_path |
ne | tourdeapp.yaml |
Cesta ke konfiguračnímu souboru |
debug |
ne | false |
Vypisuje požadavky a odpovědi API, viz Ladicí výpisy |
| Výstup | Popis |
|---|---|
upload_id |
Identifikátor nahrání |
images |
JSON pole nahraných obrazů |
deployable |
true, pokud lze nahranou aplikaci nasadit |
tourdeapp.yaml popisuje kontejnery tvé aplikace a jak sestavit jejich obrazy. Úplná specifikace je v JSON schématu. Když v souboru necháš první řádek z příkladu, editor ti bude napovídat.
# $schema: https://tourde.cloud/api/v2/schema
exposedPort: 80
containers:
- name: web
image: registry.tourde.cloud/<team-slug>/web
port: 80
- name: server
image: registry.tourde.cloud/<team-slug>/server
port: 8080
build:
- name: web
context: ./frontend
- name: server
context: ./backend
dockerfile: ./backend/docker/Dockerfile
args:
API_URL: https://example.com/apiKaždá položka v build vytvoří jeden obraz. context je ve výchozím stavu . a dockerfile je Dockerfile uvnitř contextu. Všechny cesty jsou relativní ke kořeni repozitáře, i když použiješ jiný config_path.
Kdekoli v tourdeapp.yaml můžeš napsat {{PROMENNA}} a akce to nahradí hodnotou proměnné prostředí PROMENNA. Proměnnou předej kroku přes env:
- name: Upload to Tour de Cloud
uses: studentscangrow/upload-app@v27
env:
API_KEY: ${{ secrets.API_KEY }}
with:
tdc_token: ${{ secrets.TDC_TOKEN }}build:
- name: web
context: ./frontend
args:
API_KEY: "{{API_KEY}}"Pokud proměnná chybí, nahrání selže.
Nastav debug: true a akce vypíše každý požadavek odeslaný do Tour de Cloud i každou odpověď. Stejné výpisy se zobrazí i při opětovném spuštění jobu s volbou Enable debug logging. Konfigurační soubor se vypisuje před nahrazením proměnných, takže hodnoty {{PROMENNA}} ve výpisu nejsou.
- name: Upload to Tour de Cloud
uses: studentscangrow/upload-app@v27
with:
tdc_token: ${{ secrets.TDC_TOKEN }}
debug: true