Skip to content

Commit

Permalink
[wf] push images of latest and 2nd latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
grindsa committed Dec 12, 2024
1 parent 2c758e4 commit 82d539d
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion .github/workflows/push_images_to_dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,42 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: "Retrieve Version from version.py"
- name: "Retrieve version from version.py"
run: |
echo APP_NAME=$(echo ${{ github.repository }} | awk -F / '{print $2}') >> $GITHUB_ENV
echo TAG_NAME=$(cat acme_srv/version.py | grep -i __version__ | head -n 1 | sed 's/__version__ = //g' | sed s/\'//g) >> $GITHUB_ENV
echo BUILD_NAME=${{ matrix.websrv }}-${{ matrix.dbhandler }} >> $GITHUB_ENV
- name: "Retrieve 2nd last release tag"
run: |
VERSION=$(echo ${{ env.TAG_NAME }} | awk -F. '{print $2}')
PRE_VERSION=$(($VERSION - 1))
echo $PRE_VERSION
for row in $(curl https://api.github.com/repos/grindsa/acme2certifier/tags | jq .[].name);
do
if [[ $row =~ $PRE_VERSION ]]; then
echo OLD_TAG_NAME=$(echo $row | sed s/\"//g) >> $GITHUB_ENV
echo $row
break
fi
done
- run: echo "Repo is at version ${{ steps.acme2certifier_ver.outputs.tag }}"
- run: echo "APP tag is ${{ env.APP_NAME }}"
- run: echo "Latest tag is ${{ env.TAG_NAME }}"
- run: echo "Old tag is ${{ env.OLD_TAG_NAME }}"
- run: echo "BUILD_NAME is ${{ env.BUILD_NAME}}"

- name: Checkout code for 2nd last release
uses: actions/checkout@v4
with:
ref: ${{ env.OLD_TAG_NAME }}

- name: "show version from version.py"
run: |
cat acme_srv/version.py
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
Expand All @@ -100,6 +125,39 @@ jobs:
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build with 2nd latest release tag
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: grindsa/acme2certifier:${{ env.OLD_TAG_NAME }}-${{ matrix.websrv }}-${{ matrix.dbhandler }}
file: examples/Docker/${{ matrix.websrv }}/${{ matrix.dbhandler }}/Dockerfile
platforms: linux/arm64, linux/amd64

- name: Push image to GHCR
run: |
docker buildx imagetools create \
--tag ghcr.io/grindsa/acme2certifier:${{ env.OLD_TAG_NAME }}-${{ matrix.websrv }}-${{ matrix.dbhandler }} \
grindsa/acme2certifier:${{ env.OLD_TAG_NAME }}-${{ matrix.websrv }}-${{ matrix.dbhandler }}
#- name: Delete image from registry
# run: |
# docker images
# docker rmi $(docker images grindsa/acme2certifier -q) --force

- name: Checkout code for latest release
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- uses: docker/setup-buildx-action@v3
with:
version: latest
buildkitd-flags: --debug

- name: Build with latest tag
uses: docker/build-push-action@v5
if: ${{ env.BUILD_NAME == 'apache2-wsgi'}}
Expand Down

0 comments on commit 82d539d

Please sign in to comment.