Skip to content

Commit

Permalink
Refactor release yaml to use Build and push Docker image (teragrep#65)
Browse files Browse the repository at this point in the history
* DockerFile

* Fixes for pull request 63

* removed unnecessary war file

* Added docker directory to RAT exclude because coverity fails and they don't require licensing

* Removed Coverty from CI

* Swapped Dockerfile location and swapped war location to use war file that release pipeline creates

* Dockerfile added to excluded rat list

* CFE-18 was with lowercase and not dash

* Return Coverity for merging to main repository

* Documentation changes for usage instructions

* Disable coverity for github actions testing

* Write-all was suggested in github issues. Testing that

* Wrong line. Trying again

* Build and push image test 1

* Removed external metadata gathering and using variables for tagging

* Doesn't recognize repo_lc so removing that to test if it works without

* Removed docker buildx

* Removed docker buildx

* Accidental dash in yaml :)

* Revert "Disable coverity for github actions testing"

This reverts commit de00fe2.
  • Loading branch information
Nefarious46 authored May 16, 2024
1 parent 9103e34 commit a7b6b09
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ on:
release:
types: [created]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
packages: write
contents: write
services:
mariadb:
Expand All @@ -20,9 +26,9 @@ jobs:
MYSQL_ROOT_PASSWORD: root

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout repository
uses: actions/checkout@v3


- name: Initialize MariaDB
env:
Expand Down Expand Up @@ -65,20 +71,24 @@ jobs:
files: |
target/cfe_18.war
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase repository name
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: 'Build Image'
run: |
docker buildx build --output type=docker --tag ghcr.io/${{ env.REPO_LC }}:${{ github.event.release.tag_name }} --tag ghcr.io/${{ env.REPO_LC }}:latest .
docker push ghcr.io/${{ env.REPO_LC }} --all-tags
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit a7b6b09

Please sign in to comment.