Skip to content

Commit

Permalink
ci: add nightly codespace CI
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Mar 15, 2024
1 parent d4437a7 commit ac0ec26
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .devcontainer/devcontainer.json
Expand Up @@ -24,10 +24,15 @@
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
}
},

// add labels to ports
// add labels to ports that are being used
// this will make it easier to identify what is running on each port
// it's also used by nightly builds to check all services are running as expected
"portsAttributes": {
"4280": {
"label": "Portal App",
Expand All @@ -48,10 +53,15 @@
"4300": {
"label": "Web PubSub API",
"onAutoForward": "notify"
},
"4200": {
"label": "Angular",
"onAutoForward": "notify"
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// Note: do not forward 4200 as it's being proxied by 4280
"forwardPorts": [4280, 4242, 3000, 1337],

// Use 'postCreateCommand' to run commands after the container is created.
Expand Down Expand Up @@ -90,7 +100,4 @@
"memory": "8gb",
"storage": "32gb"
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
19 changes: 19 additions & 0 deletions .github/workflows/codespaces-ci.sh
@@ -0,0 +1,19 @@
#!/bin/bash

GITHUB_REPOSITORY="Azure-Samples/contoso-real-estate"
BRANCH="codespaces-ci"
APP_PORT="4280"

# gh auth login --with-token $GITHUB_TOKEN
gh codespace create \
--repo $GITHUB_REPOSITORY \
--branch $BRANCH \
--retention-period "1h" \
--display-name "Contoso Real Estate Nightly" \
--idle-timeout "30m" \
--machine "largePremiumLinux" \
--status \
--default-permissions

# gh codespace stop -R $GITHUB_REPOSITORY
# gh codespace delete -R $GITHUB_REPOSITORY
21 changes: 21 additions & 0 deletions .github/workflows/codespaces-ci.yml
@@ -0,0 +1,21 @@
name: Nightly Codespace CI

on:
push:
branches:
- main
schedule:
# Runs every day at 4:00 AM pacific (UTC-7)
- cron: '0 12 * * *'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Deploy to Codespace
env:
GITHUB_TOKEN: ${{ secrets.CODESPACES_TOKEN }}
run: ./.github/workflows/codespaces-ci.sh

0 comments on commit ac0ec26

Please sign in to comment.