Merge remote-tracking branch 'origin/master' #11
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 ./main.go | |
- name: Create deployment directory | |
run: mkdir deployment | |
- name: Copy database file | |
run: cp ./cards.cdb ./deployment/cards.cdb | |
- name: Run web server | |
run: ./server & | |
env: | |
PORT: 8088 | |
- name: Wait for server to start | |
run: | | |
sleep 1 | |
curl -s http://localhost:8088 > index.html | |
- name: Move HTML files to deployment directory | |
run: mv templates/index.html deployment/ | |
- 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 |