edit deploy #21
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
name: Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.22' | |
- name: Cache Go modules | |
id: cache-go-mod | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Build Go web server | |
run: go build -o server | |
- name: Create deployment directory | |
run: mkdir -p deployment/static | |
- name: Copy necessary files to deployment directory | |
run: | | |
cp ./cards.cdb ./deployment/cards.cdb | |
cp -r ./static/css ./deployment/static/css | |
- name: Run web server | |
run: ./server & | |
env: | |
PORT: 8088 | |
- name: Wait for server to start | |
run: | | |
sleep 1 | |
curl -s http://localhost:8088 > deployment/index.html | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./deployment | |
publish_branch: gh-pages | |
force_orphan: true |