Fix ref #88
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: Release | |
on: | |
push: | |
branches: | |
- "main" | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
test: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- name: Test | |
run: go test -v ./... | |
- name: List directories | |
id: list-dirs | |
run: | | |
dirs=$(find ./cmd -mindepth 1 -maxdepth 1 -type d | sed 's|^\./cmd/||') | |
echo "::set-output name=dirs::$dirs" | |
- name: Format matrix | |
id: set-matrix | |
run: | | |
dirs=${{ steps.list-dirs.outputs.dirs }} | |
matrix="{\"directory\":[" | |
for dir in $dirs; do | |
matrix+="{\"name\":\"$dir\",\"image\":\"${dir##*/}\"}," | |
done | |
matrix=${matrix%,} | |
matrix+="]}" | |
echo "::set-output name=matrix::$matrix" | |
push: | |
name: Push | |
runs-on: ubuntu-latest | |
needs: test | |
strategy: | |
matrix: ${{ fromJson(needs.test.outputs.matrix) }} | |
steps: | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
name: Check out code | |
- name: Construct image metadata | |
id: image-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/TheLab-ms/profile/${{ matrix.image }} | |
tags: | | |
type=sha | |
- name: Push image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
file: ${{ matrix.directory }}/server/Dockerfile | |
tags: ${{ steps.image-meta.outputs.tags }} | |
labels: ${{ steps.image-meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |