Update workflow actions #16
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: Publish Docker image | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
env: | ||
IMAGE_NAME: bitmapist-server | ||
jobs: | ||
test: | ||
name: Test suite | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 'stable' | ||
- uses: actions/checkout@v4 | ||
- name: Get dependencies | ||
run: go mod download | ||
- name: Install redis | ||
run: sudo apt-get install -y -qq redis-server | ||
- name: Run tests | ||
run: go test -v -race ./... | ||
push: | ||
needs: test | ||
name: Build and push Docker image | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: gen-tag | ||
run: | | ||
IMAGE_TAG=${GITHUB_REF##*/} | ||
echo IMAGE_TAG | tee ci-version.txt | ||
echo "tag=$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_PACKAGES_TOKEN }} | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
platforms: | | ||
linux/arm64 | ||
linux/amd64 | ||
tags: | | ||
ghcr.io/doist/bitmapist-server:${{ steps.gen-tag.outputs.tag }} | ||
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=6,force-compression=true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |