Skip to content

Instantly share code, notes, and snippets.

@keichi
Created December 20, 2021 03:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keichi/e28ae1be7c82fe556576d2fc18ad3af6 to your computer and use it in GitHub Desktop.
Save keichi/e28ae1be7c82fe556576d2fc18ad3af6 to your computer and use it in GitHub Desktop.
name: Build and publish Docker image
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Run unit tests
run: npm test
env:
SQLITE_DB_LOCATION: /tmp/todo.db
build_and_push:
runs-on: ubuntu-latest
needs: test
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment