Skip to content

Deploy to GitHub Pages #31

Deploy to GitHub Pages

Deploy to GitHub Pages #31

Workflow file for this run

name: Deploy to GitHub Pages
on:
schedule:
- cron: '0 0 * * *' # 毎日0時に実行
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout build branch
uses: actions/checkout@v2
with:
ref: build
# c.f. https://blog.mmmcorp.co.jp/2023/08/15/github-actions-cache/
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers - App
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-app # Buildxのキャッシュを指定
key: ${{ github.ref }}-${{ github.sha }} # キャッシュのキーを指定
restore-keys: |
${{ github.ref }}
refs/head/main
- name: Build images - App
uses: docker/build-push-action@v4
with:
push: false
builder: ${{ steps.buildx.outputs.name }} # Buildxでビルドすることを指定
tags: myapp-app-cached:latest # イメージ名を指定/docker-compose.ymlで参照する名前
load: true
context: .
file: ./Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache-app # キャッシュを指定
cache-to: type=local,dest=/tmp/.buildx-cache-new-app # キャッシュを指定
- name: docker compose build & up
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
docker compose -f docker-compose.deploy.yaml build
docker compose -f docker-compose.deploy.yaml up -d
#docker compose -f docker-compose.deploy.yaml exec -T paper_notes-temp_container-1 bundle install
#docker compose -f docker-compose.deploy.yaml exec -T paper_notes-temp_container-1 sh -c "cd /app && python generate_html.py && bundle exec jekyll build"
docker cp paper_notes-temp_container-1:/app/_site ${{ github.workspace }}
docker rm paper_notes-temp_container-1
- name: Commit and push to build
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add _site/*
git commit -m "Automated deployment: $(date +'%Y-%m-%d %H:%M:%S')"
git push origin build