Skip to content

Commit

Permalink
extract branch name correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Apr 21, 2024
1 parent f65810b commit 8518692
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ jobs:

docker:
needs: [build]
uses: ./.github/workflows/step_docker.yml
with:
registry: "docker.io"
organization: ${{ inputs.docker_hub_organization }}
runs-on: ubuntu-latest
steps:
- uses: ./.github/workflows/step_docker.yml
with:
registry: "docker.io"
organization: ${{ inputs.docker_hub_organization }}
login: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

# quay:
# needs: [build]
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/step_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Get branch
id: get_branch
run: |
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
echo "::set-output name=branch::$(echo ${GITHUB_REF##*/})"
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "::set-output name=branch::$(echo $GITHUB_BASE_REF)"
else
echo "::set-output name=branch::INVALID_EVENT_BRANCH_UNKNOWN"
fi
- name: Download go build artifacts
uses: actions/download-artifact@v3
with:
Expand All @@ -38,7 +49,7 @@ jobs:
- name: Build container images
run: |
current_tag=${GITHUB_REF#refs/*/}
make docker DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker DOCKER_IMAGE_TAG=${{ steps.get_branch.outputs.branch }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
docker images
shell: bash

Expand All @@ -49,10 +60,7 @@ jobs:
- name: Publish image for main branch
if: github.ref == 'refs/heads/main'
run: |
echo ${DOCKER_HUB_PASSWORD} | docker login -u ${DOCKER_HUB_LOGIN} --password-stdin ${{ inputs.registry }}
make docker-publish DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
echo ${{ inputs.password }} | docker login -u ${{ inputs.login }} --password-stdin ${{ inputs.registry }}
make docker-publish DOCKER_IMAGE_TAG=${{ steps.get_branch.outputs.branch }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG=${{ steps.get_branch.outputs.branch }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
shell: bash
env:
DOCKER_HUB_LOGIN: ${{ secrets.DOCKER_HUB_LOGIN }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}

0 comments on commit 8518692

Please sign in to comment.