52 lines
2.0 KiB
YAML
52 lines
2.0 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Read package.json version
|
|
id: package-version
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Building version: $VERSION"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Registry
|
|
# Gitea automatically provides these secrets:
|
|
# - `vars.REGISTRY_USERNAME` - defined as action variable in repo settings
|
|
# - `secrets.REGISTRY_TOKEN` - defined as action secret in repo settings
|
|
# created in user settings as personal access token with `write:packages` scope
|
|
# - `vars.PROFILE_REGISTRY_TOKEN` - defined as action variable in profile settings
|
|
# - `secrets.PROFILE_REGISTRY_TOKEN` - defined as action secret in profile settings
|
|
# created in user settings as personal access token with `write:packages` scope
|
|
run: |
|
|
echo "${{ secrets.PROFILE_REGISTRY_TOKEN }}" | docker login registry.budakova.org -u "${{ vars.PROFILE_REGISTRY_TOKEN }}" --password-stdin
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
registry.budakova.org/knee-cola/gitea-actions-demo-project:${{ steps.package-version.outputs.version }}
|
|
registry.budakova.org/knee-cola/gitea-actions-demo-project:latest
|
|
cache-from: type=registry,ref=registry.budakova.org/knee-cola/gitea-actions-demo-project:buildcache
|
|
cache-to: type=registry,ref=registry.budakova.org/knee-cola/gitea-actions-demo-project:buildcache,mode=max
|