From 0fc4405b572ef5b2cdb92c4814d9a57bc7de2083 Mon Sep 17 00:00:00 2001 From: Tim Zabel Date: Sun, 27 Oct 2024 19:58:32 -0400 Subject: [PATCH] Rename Go GHA workflow to main.yml --- .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 ee29b1a..0000000 --- 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 811508e..6d3c75c 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 0000000..822d48f --- /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 }}