Update cache paths in build-test.yaml #136
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: Build Docker Image | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
ImageBuild: | |
name: Build Walnuts.dev Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Slack notification of build start | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_USERNAME: GitHub Actions | |
SLACK_COLOR: '#4381de' | |
SLACK_ICON: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' | |
SLACK_TITLE: Start Walnuts.dev image build | |
SLACK_MESSAGE: | | |
Run number : #${{ github.run_number }} | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Cache node_modules, .next/cache, .npm | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
.next/cache | |
.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: install | |
run: npm install | |
- name: build | |
run: npm run build | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: walnuts1018 | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
ghcr.io/walnuts1018/walnuts.dev:latest | |
ghcr.io/walnuts1018/walnuts.dev:${{ github.sha }}-${{ github.run_number }} | |
SucceessNotification: | |
if: ${{ success() }} | |
name: Send Success Message | |
needs: [ImageBuild] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Message to Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_USERNAME: GitHub Actions | |
SLACK_ICON: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' | |
SLACK_TITLE: Walnuts.dev image build succeeded | |
SLACK_MESSAGE: | | |
Image: Walnuts.dev | |
Run number : #${{ github.run_number }} | |
FailureAlert: | |
if: ${{ failure() }} | |
name: Notify failure | |
needs: [ImageBuild] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Failure Alert to Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_USERNAME: GitHub Actions | |
SLACK_ICON: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' | |
SLACK_TITLE: Walnuts.dev image build failed | |
SLACK_COLOR: danger | |
SLACK_MESSAGE: | | |
Image: Walnuts.dev | |
Run number : #${{ github.run_number }} |