From f2cf389950f34fe27400103faaf8bac439d4e4d1 Mon Sep 17 00:00:00 2001 From: "Gregg B. Jensen" Date: Thu, 15 Aug 2024 20:13:17 -0600 Subject: [PATCH] Docker release fixes (#52) --- .github/actions/deploy-tags/README.md | 8 ++++++++ .github/actions/deploy-tags/action.yaml | 16 +++++++++++----- .github/workflows/_container-build.yaml | 8 ++++++++ .github/workflows/charts-build.yaml | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/actions/deploy-tags/README.md b/.github/actions/deploy-tags/README.md index 7342250..d8fa8b6 100644 --- a/.github/actions/deploy-tags/README.md +++ b/.github/actions/deploy-tags/README.md @@ -2,6 +2,12 @@ Gets a set of release tags for deployment of Docker images and helm charts, this included `latest` and multiple versions like `1.2.15`, `1.2`, and `1`. +## Inputs + +### `repository` + +The docker repository to generate tags for. Example: `greggbjensen/prdeploy` + ## Outputs ### `tags` @@ -14,6 +20,8 @@ The comma separated list of tags to use. - name: Deploy tags id: deploy_tags uses: greggbjensen/prdeploy/.github/actions/deploy-tags@main + with: + image: ${{ inputs.service_name }} - name: Docker build and push uses: docker/build-push-action@v5 diff --git a/.github/actions/deploy-tags/action.yaml b/.github/actions/deploy-tags/action.yaml index 1d36c60..526825e 100644 --- a/.github/actions/deploy-tags/action.yaml +++ b/.github/actions/deploy-tags/action.yaml @@ -1,5 +1,9 @@ name: Date version description: Gets a set of release tags for deployment of Docker images and helm charts, this included `latest` and multiple versions like `1.2.15`, `1.2`, and `1`. +inputs: + repository: + required: true + description: The docker repository to generate tags for. outputs: tags: value: ${{ steps.deploy_tags.outputs.tags }} @@ -13,7 +17,8 @@ runs: id: deploy_tags shell: bash env: - RELEASE_TAG: ${{ (github.event_name == 'release' && github.event.release.tag_name) && format('greggbjensen/{0}:latest, greggbjensen/{0}:{1}', inputs.service_name, github.event.release.tag_name) || format('greggbjensen/{0}:temp', inputs.service_name) }} + REPOSITORY: ${{ inputs.repository }} + RELEASE_TAG: ${{ (github.event_name == 'release' && github.event.release.tag_name) && github.event.release.tag_name || 'temp' }} run: | if [ "$RELEASE_TAG" == "temp" ]; then echo "tags=temp" >> $GITHUB_OUTPUT @@ -21,8 +26,9 @@ runs: fi IFS='.' read -ra parts <<< "$RELEASE_TAG" - patch=$RELEASE_TAG - minor="${parts[0]}.${parts[1]}" - major="${parts[0]}" - tags="$patch, $minor, $major, latest" + patch="$REPOSITORY:$RELEASE_TAG" + minor="$REPOSITORY:${parts[0]}.${parts[1]}" + major="$REPOSITORY:${parts[0]}" + latest="$REPOSITORY:latest" + tags="$patch, $minor, $major, $latest" echo "tags=$tags" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/_container-build.yaml b/.github/workflows/_container-build.yaml index 9c1cd5f..cf1a2fa 100644 --- a/.github/workflows/_container-build.yaml +++ b/.github/workflows/_container-build.yaml @@ -45,3 +45,11 @@ jobs: tags: ${{ steps.deploy_tags.outputs.tags }} file: ${{ inputs.service_name }}/Dockerfile context: ${{ inputs.service_name }} + + - name: Docker Hub description + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: greggbjensen/${{ inputs.service_name }} + readme-filepath: ${{ inputs.service_name }}/README.md diff --git a/.github/workflows/charts-build.yaml b/.github/workflows/charts-build.yaml index 9ba06d1..feb33bf 100644 --- a/.github/workflows/charts-build.yaml +++ b/.github/workflows/charts-build.yaml @@ -76,5 +76,5 @@ jobs: charts=$(find ./helm-charts -maxdepth 1 -name "*.tgz") for chart in $charts do - helm push $chart oci://registry-1.docker.io/greggbjensen/charts + helm push $chart oci://registry-1.docker.io/greggbjensen done