Skip to content

Commit

Permalink
fix: unify ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshounshell authored and xbglowx committed Aug 10, 2023
1 parent a09e77f commit 437ae0d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 75 deletions.
77 changes: 48 additions & 29 deletions .github/workflows/build.yaml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: build
name: Build/Publish Docker Image
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
Expand All @@ -14,14 +12,47 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
container-build:
build-and-publish:
name: Build/Publish Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
- name: Check out the repo
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
ML_PROJECT_VERSION=$(TZ=UTC git --no-pager log -n1 --date="format-local:%Y%m%dT%H%M%S" --pretty="format:%cd-%h" --abbrev=7)
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
# Tag with both registries GHCR and
if [ '${{ github.event_name != 'pull_request' }}' == 'true' ]; then
# release to all registries
GHCR=ghcr.io/${GITHUB_REPOSITORY,,}
ARTIFACTORY=docker.pennywise.cc/${GITHUB_REPOSITORY,,}
TAGS="${ARTIFACTORY}:${VERSION},${GHCR}:${VERSION},${ARTIFACTORY}:$ML_PROJECT_VERSION,${GHCR}:$ML_PROJECT_VERSION"
else
# only internal staging
ARTIFACTORY="docker-builds.pennywise.cc/${GITHUB_REPOSITORY,,}"
TAGS="$ARTIFACTORY:$ML_PROJECT_VERSION"
fi
# outputs
for out in "version=${VERSION}" "tags=${TAGS}" "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"; do
# echo "k=v" >> $GITHUB_OUTPUT
echo $out | tee >(cat) >> $GITHUB_OUTPUT
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -39,6 +70,13 @@ jobs:
endpoint: builders
buildkitd-flags: --debug --allow-insecure-entitlement network.host

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

- name: Login to docker.pennywise.cc
uses: docker/login-action@v2
with:
Expand All @@ -53,31 +91,12 @@ jobs:
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: dockerfile lint
uses: rusty-actions/dockerfile-linter@v1
continue-on-error: true

- name: generate tags
id: tags
run: |
DOCKER_IMAGE=docker-builds.pennywise.cc/${GITHUB_REPOSITORY,,}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=latest
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Build and push
uses: docker/build-push-action@v4
- name: Build and Push
uses: docker/build-push-action@v2
with:
allow: network.host
push: true
tags: ${{ steps.tags.outputs.TAGS }}
tags: ${{ steps.prep.outputs.tags }}
file: Dockerfile
context: .
cache-from: type=gha
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/main.yml

This file was deleted.

0 comments on commit 437ae0d

Please sign in to comment.