From e5d310ac113e1c471782e21b955f024940df3f72 Mon Sep 17 00:00:00 2001 From: Alexander Gil Date: Sat, 13 Jan 2024 13:09:09 +0100 Subject: [PATCH] ci: Add docker image automatic build --- .github/workflows/docker.yml | 23 +++++++++++ .github/workflows/main.yml | 79 ------------------------------------ Makefile | 2 +- 3 files changed, 24 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..f0a2fe6 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,23 @@ +name: Docker Image Push + +on: + push: + branches: + - master + +jobs: + build-and-push: + runs-on: ubuntu-latest + env: + IMAGE_NAME: ghcr.io/${{ github.actor }}/transcoder + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push Docker Image + run: | + IMAGE_VERSION=$(git rev-parse --short HEAD) make push-images + IMAGE_VERSION=latest make push-images diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 8056460..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: CI -on: - push: - branches: master - tags: - - v*.* - pull_request: -jobs: - docker: - if: github.event_name == 'push' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - lfs: true - - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" - id: branch - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: build server docker - uses: docker/build-push-action@v3 - with: - file: server/Dockerfile - tags: segator/transcoderd:${{ steps.branch.outputs.branch }} - push: true - - run: | - sudo swapoff -a - sudo rm -f /swapfile - sudo apt clean - docker system prune --volumes -f - - name: build worker docker - uses: docker/build-push-action@v3 - with: - file: worker/Dockerfile.encode - tags: segator/encoder-agent:${{ steps.branch.outputs.branch }} - push: true - - name: build worker docker PGS - uses: docker/build-push-action@v3 - with: - file: worker/Dockerfile.pgs - tags: segator/pgs-agent:${{ steps.branch.outputs.branch }} - push: true - binary: - strategy: - fail-fast: false - matrix: - os: ["ubuntu", "windows", "macos"] - runs-on: ${{ matrix.os}}-latest - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.19 - - name: Checkout - uses: actions/checkout@v2 - with: - lfs: true - - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" - shell: bash - id: branch - - name: Build Server - run: | - go run build.go build server -p ${{matrix.os}}-amd64 - - name: Build Workers - run: | - go run build.go build worker -p ${{matrix.os}}-amd64 -m console - - name: Upload Release Asset - if: github.event_name == 'push' - id: upload-release-asset - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: wip-${{ steps.branch.outputs.branch }} - file: dist/* - overwrite: true - file_glob: true diff --git a/Makefile b/Makefile index b29f703..32143f4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOOPTS ?= GOOS ?= $(shell $(GO) env GOHOSTOS) GOARCH ?= $(shell $(GO) env GOHOSTARCH) -IMAGE_NAME ?= pando85/transcoder +IMAGE_NAME ?= ghcr.io/pando85/transcoder IMAGE_VERSION ?= latest .DEFAULT: help