Skip to content

Commit f76ae60

Browse files
committed
Adds ghr workflow
1 parent b2c45c3 commit f76ae60

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/docker.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- Stable-Test
8+
- QA-Test
9+
tags:
10+
- 'v*'
11+
pull_request:
12+
branches:
13+
- master
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Debug event information
35+
run: |
36+
echo "Event name: ${{ github.event_name }}"
37+
echo "Ref: ${{ github.ref }}"
38+
echo "Is default branch: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}"
39+
echo "Should push: ${{ github.event_name != 'pull_request' }}"
40+
41+
- name: Log in to Container Registry
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Extract metadata
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
tags: |
54+
# set latest tag for master branch
55+
type=raw,value=latest,enable={{is_default_branch}}
56+
# branch event
57+
type=ref,event=branch
58+
# tag event
59+
type=ref,event=tag
60+
# pull request event
61+
type=ref,event=pr
62+
# sha (only for non-PR events)
63+
type=sha,enable={{is_default_branch}}
64+
65+
- name: Build and push Docker image
66+
id: build-and-push
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
platforms: linux/amd64,linux/arm64
71+
push: true
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max
76+
77+
- name: Image digest
78+
run: echo ${{ steps.build-and-push.outputs.digest }}
79+
80+
- name: Instructions for making package public
81+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
82+
run: |
83+
echo "🚀 Docker image pushed successfully!"
84+
echo "📦 Image available at: ghcr.io/${{ github.repository }}"
85+
echo ""
86+
echo "ℹ️ To make this package publicly accessible:"
87+
echo "1. Go to https://github.com/${{ github.repository }}/pkgs/container/liquidity-bridge-contract"
88+
echo "2. Click 'Package settings'"
89+
echo "3. Scroll down to 'Danger Zone'"
90+
echo "4. Click 'Change visibility'"
91+
echo "5. Select 'Public' and confirm"
92+
echo ""
93+
echo "After making it public, anyone can pull with:"
94+
echo "docker pull ghcr.io/${{ github.repository }}:latest"

0 commit comments

Comments
 (0)