From 6af8bbfa1e3f03dc4174f9898b67e97492da0e46 Mon Sep 17 00:00:00 2001 From: Tim Zabel Date: Fri, 15 Nov 2024 21:30:53 -0500 Subject: [PATCH 08/10] Rename Go GHA workflow to main.yml (#426) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Signed-off-by: Alexander Miroshnichenko --- .github/workflows/go.yml | 32 ------------ .github/workflows/main.yml | 61 +++++++--------------- .github/workflows/publish_docker_image.yml | 49 +++++++++++++++++ 3 files changed, 68 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/publish_docker_image.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ee29b1ad3e11..000000000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - -name: Go - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - - build: - runs-on: ubuntu-latest - strategy: - matrix: - go: [ '1.18', '1.19', '1.20' ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - - name: Build TeleIRC - run: ./build_binary.sh - - - name: Test - run: go test -v ./... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 811508e8dadf..6d3c75c5ec74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,54 +1,31 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. +name: Build and Test TeleIRC -name: Docker - -on: - push: - branches: [main] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} +on: [push] +# Cancel job in favor of newer commit concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: go-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - build-and-push-image: - name: Build and Push Image - + build: runs-on: ubuntu-latest - permissions: - contents: read - packages: write + strategy: + matrix: + go-version: [ '1.18', '1.19', '1.20' ] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build TeleIRC + run: ./build_binary.sh - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - push: true - context: . - file: ./deployments/container/Dockerfile - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + - name: Test + run: go test -v ./... diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml new file mode 100644 index 000000000000..822d48f8ef34 --- /dev/null +++ b/.github/workflows/publish_docker_image.yml @@ -0,0 +1,49 @@ +name: Build and Push Docker Image + +on: + push: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +concurrency: + group: teleirc-docker-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push-image: + name: Build and Push Image + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + push: true + context: . + file: ./deployments/container/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} -- 2.41.0