Fix GitHub actions #7
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: Lint, Test, and Publish Docker Image | |
on: | |
push: | |
branches: ["main"] | |
# Publish semver tags as releases. | |
tags: ["v*.*.*"] | |
jobs: | |
lint-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: Lint | |
run: bun lint | |
- name: Test | |
run: bun test | |
build: | |
needs: lint-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Lint Dockerfile | |
uses: hadolint/hadolint-action@v3.1.0 | |
with: | |
dockerfile: Dockerfile | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: wingriders/cab-backend | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=semver,pattern=v{{version}} | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
provenance: false | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |