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

Commit 05be4dd

Browse files
Fix/private repo (#5)
* revert to v0.1.1 * fix: supporting private repositories
1 parent 2af2233 commit 05be4dd

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
build_tag_push_to_ghcr:
3333
runs-on: ubuntu-latest
3434
steps:
35-
# - uses: actions/checkout@v2
3635
- name: Build, Tag and Push Docker Image to GHCR
3736
uses: GlueOps/[email protected]
3837
```

action.yml

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ inputs:
1010
description: "Personal Access Token (PAT) used to authenticate with the GitHub Container Registry."
1111
required: true
1212
default: ${{ github.token }}
13-
14-
your_pat:
15-
description: "Personal Access Token (PAT) used to authenticate with GitHub and the GitHub Container Registry."
16-
required: true
1713

1814
image_name:
1915
description: 'Docker image is named after repository'
@@ -60,9 +56,8 @@ runs:
6056
export BRANCH_NAME="${GITHUB_REF#refs/heads/}"
6157
export BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
6258
echo "Current branch is: $BRANCH_NAME"
63-
64-
# git clone --depth 1 --branch $BRANCH_NAME https://${{ inputs.your_pat }}@github.com/owner/repo .
65-
git clone --depth=1 --branch="$BRANCH_NAME" "https://${DOCKER_IO_USER}:${{ inputs.your_pat }}@github.com/${{ github.repository }}" .
59+
60+
git clone --depth=1 --branch="$BRANCH_NAME" "https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}" .
6661
echo "Using $(docker -v)"
6762
echo "::endgroup::"
6863
@@ -78,23 +73,39 @@ runs:
7873
echo "::group::Set commit tags"
7974
echo "Event payload: ${{ toJson(github.event_name) }}"
8075
81-
if [ -z "${IMAGE_TAG}" ]; then
82-
BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
83-
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
84-
BRANCH_NAME=${BRANCH_NAME////-} # Replace slashes with hyphens
85-
BRANCH_NAME=${BRANCH_NAME//[^a-zA-Z0-9_.-]/_} # Replace invalid characters with underscores
86-
BRANCH_NAME=${BRANCH_NAME// /_} # Replace whitespaces with underscores
87-
BRANCH_NAME=${BRANCH_NAME,,} # Convert to lowercase
88-
89-
export COMMIT_TAG="$BRANCH_NAME"
90-
export SHA="${{ github.sha }}"
91-
export SHORT_SHA="${SHA:0:7}"
76+
#for release events, the tag name is available as github.event.release.tag_name, long SHA as github.sha and short SHA as github.sha_short
77+
# if [ "${{ github.event_name }}" = "release" ]; then
78+
# export TAG_NAME="${{ github.event.release.tag_name }}"
79+
# export COMMIT_TAG="${TAG_NAME#refs/tags/}"
80+
# export SHA="${{ github.sha }}"
81+
# export SHORT_SHA="${SHA:0:7}"
9282
93-
echo "Branch Name ${COMMIT_TAG}"
94-
echo "Short SHA ${SHORT_SHA}"
95-
echo "Long SHA ${SHA}"
96-
fi
97-
83+
# echo "Release Version ${COMMIT_TAG}"
84+
# echo "Short SHA ${SHORT_SHA}"
85+
# echo "Long SHA ${SHA}"
86+
87+
# else
88+
#for commits, the tag name is available as github.ref, long SHA as github.sha and short SHA as github.sha_short
89+
if [ -z "${IMAGE_TAG}" ]; then
90+
BRANCH_NAME="${BRANCH_NAME#refs/tags/}"
91+
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
92+
93+
94+
# BRANCH_NAME="${BRANCH_NAME#refs/heads/}" # Remove refs/heads/ prefix
95+
BRANCH_NAME=${BRANCH_NAME////-} # Replace slashes with hyphens
96+
BRANCH_NAME=${BRANCH_NAME//[^a-zA-Z0-9_.-]/_} # Replace invalid characters with underscores
97+
BRANCH_NAME=${BRANCH_NAME// /_} # Replace whitespaces with underscores
98+
BRANCH_NAME=${BRANCH_NAME,,} # Convert to lowercase
99+
export COMMIT_TAG="$BRANCH_NAME"
100+
export SHA="${{ github.sha }}"
101+
export SHORT_SHA="${SHA:0:7}"
102+
103+
echo "Branch Name ${COMMIT_TAG}"
104+
echo "Short SHA ${SHORT_SHA}"
105+
echo "Long SHA ${SHA}"
106+
fi
107+
# fi
108+
98109
# convert the image name to lowercase
99110
export IMAGE_NAME=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
100111
echo "::endgroup::"

0 commit comments

Comments
 (0)