From 5d1b5b5faaa73cc9cc3022323e90d626a00534aa Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Tue, 13 Aug 2024 20:54:38 -0700 Subject: [PATCH] docker: GitHub actions testing for docker release - Temporarily adding `rc` tag trigger for testing `Build and push multi-platform docker images` action flow before the final release. - Added some variable inputs for testing like repo, platforms, etc. - Added more logs for future debugging. --- .github/workflows/docker-release.yml | 76 +++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index bd4cf2349f3f..131bf152d147 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -3,13 +3,28 @@ name: Build and push multi-platform docker images on: push: tags: - - '^v[0-9]{2}\.[0-9]{2}(\.[0-9]{1,2})?$' + - '^v[0-9]{2}\.[0-9]{2}(\.[0-9]{1,2})?([a-zA-Z0-9]*)?$' workflow_dispatch: inputs: version: description: 'Release version' required: true + repository-name: + description: 'Docker repository name' + default: 'elementsproject' + required: false + + platforms-to-build: + description: 'List of platforms to build' + default: 'linux/amd64,linux/arm64,linux/arm/v7' + required: false + + push-latest: + description: 'Push the latest tag also?' + default: 'false' + required: false + jobs: build: runs-on: ubuntu-latest @@ -30,8 +45,8 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Set up version - id: set-version + - name: Set up values + id: set-values run: | if [ "${{ github.event.inputs.version }}" != "" ]; then VERSION=${{ github.event.inputs.version }} @@ -42,13 +57,58 @@ jobs: exit 1 fi echo "VERSION=$VERSION" >> $GITHUB_ENV - + + if [ "${{ github.event.inputs.repository-name }}" != "" ]; then + REPONAME=${{ github.event.inputs.repository-name }} + else + REPONAME="elementsproject" + fi + echo "REPONAME=$REPONAME" >> $GITHUB_ENV + + if [ "${{ github.event.inputs.platforms-to-build }}" != "" ]; then + PLATFORMS=${{ github.event.inputs.platforms-to-build }} + else + PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7" + fi + echo "PLATFORMS=$PLATFORMS" >> $GITHUB_ENV + + if [ + "${{ github.event.inputs.push-latest }}" == "true" || + ( "${{ github.ref_type }}" == "tag" && [[ ! "${{ env.VERSION }}" =~ rc ]] ) + ]; then + PUSHLATEST="true" + else + PUSHLATEST="false" + fi + echo "PUSHLATEST=$PUSHLATEST" >> $GITHUB_ENV + + - name: Set Tags + id: set-tags + run: | + TAGS="${{ env.REPONAME }}/lightningd:${{ env.VERSION }}" + if [ "${{ env.PUSHLATEST }}" == "true" ]; then + TAGS="$TAGS,${{ env.REPONAME }}/lightningd:latest" + fi + echo "TAGS=$TAGS" >> $GITHUB_ENV + + - name: Print GitHub Ref Values + run: | + echo "GITHUB REF TYPE: ${{ github.ref_type }}" + echo "GITHUB REF NAME: ${{ github.ref_name }}" + echo "EVENT INPUT VERSION: ${{ github.event.inputs.version }}" + echo "EVENT INPUT REPO: ${{ github.event.inputs.repository-name }}" + echo "EVENT INPUT PLATFORMS: ${{ github.event.inputs.platforms-to-build }}" + echo "EVENT INPUT PUSH LATEST: ${{ github.event.inputs.push-latest }}" + echo "VERSION ENV: ${{ env.VERSION }}" + echo "REPO NAME: ${{ env.REPONAME }}" + echo "PLATFORMS: ${{ env.PLATFORMS }}" + echo "PUSH LATEST: ${{ env.PUSHLATEST }}" + echo "TAGS: ${{ env.TAGS }}" + - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . push: true - platforms: linux/amd64,linux/arm64,linux/arm/v7 - tags: | - elementsproject/lightningd:$VERSION - elementsproject/lightningd:latest + platforms: ${{ env.PLATFORMS }} + tags: ${{ env.TAGS }}