Skip to content
This repository has been archived by the owner on Dec 29, 2024. It is now read-only.

Commit

Permalink
Simplify CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
kiorky committed Oct 12, 2024
1 parent e300053 commit 577685d
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
FORCE_ONLINE: "1"
CORPUSOPS_ROLES_BRANCH: "4.0"
RELEASABLE_REPOS: "^corpusops/"
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|2.0|3.0|4.0|workflows)$"
RELEASABLE_BRANCHES: "^(refs/heads/)?(4.0)$"
jobs:
r:
runs-on: ubuntu-latest
Expand All @@ -16,18 +16,12 @@ jobs:
run: |-
tags="${{matrix.image}}_preprovision-${{matrix.ansible_release}}"
rtags="${{matrix.image}}-${{matrix.ansible_release}}"
if [[ -n "${{matrix.ansible_latest}}" ]];then
if [[ "${{matrix.ansible_release }}" == "${{matrix.ansible_latest}}" ]];then
tags="$tags ${{matrix.image}}_preprovision"
rtags="$rtags ${{matrix.image}}"
fi
fi
if ( echo "$GITHUB_REF" | egrep -q "${RELEASABLE_BRANCHES}" ) \
&& ( echo "$GITHUB_REPOSITORY" | egrep -q "${RELEASABLE_REPOS}" )
then releasable=true;else releasable=false;fi
echo "releasable=$releasable" >> $GITHUB_OUTPUT
echo "tags=$tags" >> $GITHUB_OUTPUT
echo "rtags=$rtags" >> $GITHUB_OUTPUT
echo "tags=$tags" >> $GITHUB_OUTPUT
echo "rtags=$rtags" >> $GITHUB_OUTPUT
id: v
- name: Login to Docker Hub
uses: docker/login-action@v2
Expand Down Expand Up @@ -73,45 +67,24 @@ jobs:
run: |-
set -ex
iid=$(mktemp)
siid=$(mktemp)
if [[ -z $NO_SQUASH ]];then sq='--squash';else sq="";fi
img=${{matrix.image}}_preprovision-${{matrix.ansible_release}}
# docker build --iidfile $iid \
# --cache-from="${img}-nosquash" --cache-from="$img" \
# -f "docker/${img}" . --build-arg FORCE_ONLINE=1
docker build --iidfile $iid \
-f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.tags}};do
for t in $i ${i}-nosquash;do docker tag $(cat $iid) $t;done;done
if [[ -z $NO_SQUASH ]];then
docker build $sq --iidfile $siid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.tags}};do docker tag $(cat $siid) $i;done
fi
docker build --iidfile $iid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.tags}};do for t in $i;do docker tag $(cat $iid) $t;done;done
- name: Build 2nd round image
id: docker_build2
run: |-
set -ex
iid=$(mktemp)
siid=$(mktemp)
if [[ -z $NO_SQUASH ]];then sq='--squash';else sq="";fi
img=${{matrix.image}}-${{matrix.ansible_release}}
# docker build --iidfile $iid --cache-from="$img" -f "docker/${img}" . --build-arg FORCE_ONLINE=1
docker build --iidfile $iid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.rtags}};do
for t in $i ${i}-nosquash;do docker tag $(cat $iid) $t;done;done
if [[ -z $NO_SQUASH ]];then
docker build $sq --iidfile $siid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.rtags}};do docker tag $(cat $siid) $i;done
fi
for i in ${{steps.v.outputs.rtags}};do for t in $i;do docker tag $(cat $iid) $t;done;done
- name: Push images if needed
run: |-
set -ex;for i in ${{steps.v.outputs.tags}} ${{steps.v.outputs.rtags}};do
if [[ -z $NO_SQUASH ]];then docker push ${i}-nosquash;fi;docker push $i;done
set -ex;for i in ${{steps.v.outputs.tags}} ${{steps.v.outputs.rtags}};do docker push $i;done
if: ${{steps.v.outputs.releasable == 'true'}}
strategy:
fail-fast: false
matrix:
ansible_latest: ["2.17"]
ansible_release: ["2.17"]
image:
- "corpusops/ubuntu:24.04"
Expand Down

0 comments on commit 577685d

Please sign in to comment.