Skip to content

Commit 8e3ed74

Browse files
committed
refactored workflows + added login for ghcr
Signed-off-by: pco <pasquale.convertini@ibm.com>
1 parent 852ddd6 commit 8e3ed74

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

.github/workflows/build-image.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,46 @@ jobs:
2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
24+
2425
- name: Set up QEMU for cross-platform builds
2526
uses: docker/setup-qemu-action@v3
27+
2628
- name: Set up Docker Buildx
2729
uses: docker/setup-buildx-action@v3
30+
2831
- name: Log in to Docker Hub
2932
uses: docker/login-action@v3
3033
with:
3134
username: ${{ secrets.DOCKERHUB_USERNAME }}
3235
password: ${{ secrets.DOCKERHUB_TOKEN }}
33-
- name: Extract version from tag
34-
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
36+
37+
- name: Log in to GitHub Container Registry
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Extract and Validate Version from Tag
45+
id: extract
46+
run: |
47+
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
48+
VERSION="${BASH_REMATCH[1]}"
49+
echo "VERSION=$VERSION" >> $GITHUB_ENV
50+
echo "✅ Tag validated: $VERSION"
51+
else
52+
echo "❌ Invalid tag format: ${GITHUB_REF}. Expected format: refs/tags/v<semver>"
53+
exit 1
54+
fi
55+
56+
- name: Set image prefix
57+
run: |
58+
if [ "$GITHUB_REPOSITORY_OWNER" == "hyperledger" ]; then
59+
echo "IMAGE_PREFIX=hyperledger" >> $GITHUB_ENV
60+
else
61+
echo "IMAGE_PREFIX=${{ secrets.DOCKERHUB_USERNAME }}" >> $GITHUB_ENV
62+
fi
63+
3564
- name: Build and push the fabric-x-tools image
3665
uses: docker/build-push-action@v6
3766
with:
@@ -42,5 +71,7 @@ jobs:
4271
build-args: |
4372
FABRIC_X_VERSION=${{ github.ref_name }}
4473
tags: |
45-
docker.io/hyperledger/fabric-x-tools:${{ env.VERSION }}
46-
docker.io/hyperledger/fabric-x-tools:latest
74+
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-tools:${{ env.VERSION }}
75+
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-tools:latest
76+
ghcr.io/${{ env.IMAGE_PREFIX }}/fabric-x-tools:${{ env.VERSION }}
77+
ghcr.io/${{ env.IMAGE_PREFIX }}/fabric-x-tools:latest

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ jobs:
1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@v4
22+
2223
- name: Setup Go
2324
uses: actions/setup-go@v5
2425
with:
2526
go-version-file: go.mod
27+
2628
- name: Install lint utilities
2729
run: |
2830
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
31+
2932
- name: Run lint
3033
run: |
3134
git fetch origin main:refs/remotes/origin/main

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ jobs:
1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@v4
22+
2223
- name: Setup Go
2324
uses: actions/setup-go@v5
2425
with:
2526
go-version-file: go.mod
27+
2628
- name: Install tests utilities
2729
run: |
2830
go install "github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest"
31+
2932
- name: Run unit tests
3033
run: make test

0 commit comments

Comments
 (0)