diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..e7bcaa1 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,67 @@ +--- +name: Docker Build Action +on: + pull_request: + branches: + - master + release: + types: + - published + push: + branches: + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + name: Docker Build + runs-on: ubuntu-latest + + steps: + - name: Log in to the container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_REGISTRY_USER }} + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + + - name: Install libsystemd headers + run: sudo apt-get update && sudo apt-get install libsystemd-dev + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: false + + - name: Lint + uses: golangci/golangci-lint-action@v6 + with: + args: --build-tags integration -p bugs -p unused -D protogetter --timeout=5m + + - name: Make tag + run: | + [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true + + - name: Push server image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} + + - name: Push client image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.client + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-client:${{ env.tag }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index 78afa43..0000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Docker Image from master - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=${GITHUB_HEAD_REF##*/} - make dockerimage - make dockerpush - - - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 05585fe..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Docker Image from master - -on: - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Figure out if running fork PR - id: fork - run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"' - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - if: steps.fork.outputs.is_fork_pr == 'false' - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - # pull request images are prefixed with 'pr' to prevent them from overriding released images - export GITHUB_TAG_NAME=pr-${GITHUB_HEAD_REF##*/} - make dockerimage - make dockerpush - if: steps.fork.outputs.is_fork_pr == 'false' diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..f0e8eae --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,15 @@ +--- +name: Release Drafter Action + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index a3b78a5..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Docker Image from release tags - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=${GITHUB_REF##*/} - make dockerimage - make dockerpush \ No newline at end of file