Skip to content

chore: added ci.yaml and removed other workflows #3

chore: added ci.yaml and removed other workflows

chore: added ci.yaml and removed other workflows #3

Workflow file for this run

name: CI
on: [pull_request, push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Build code
run: go build -o bin/mq cmd/mq/main.go
- name: Run tests
run: go test ./...
- name: Check if PR can be merged
if: github.event_name == 'pull_request'
run: |
if [ $? -ne 0 ]; then
echo "Tests failed, PR cannot be merged!"
exit 1
fi
release:
needs: test
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build and push Docker image (multi-arch) to ghcr.io
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t ghcr.io/${{ github.repository_owner }}/mq:${{ steps.version.outputs.TAG_NAME }} \
-t ghcr.io/${{ github.repository_owner }}/mq:latest \
--push .