Skip to content

Commit 963fb8f

Browse files
authored
Merge pull request #18 from Shayan-Ghani/ci
chore(ci): added docker hub push after release
2 parents ef8b879 + 3b8faba commit 963fb8f

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ on:
1111
- '.gitignore'
1212
- 'LICENSE'
1313

14-
permissions:
15-
contents: write
16-
pull-requests: read
1714

1815
env:
19-
ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest
20-
docker_repo_addr: shayanghani/container-exporter:latest
21-
docker_hub_user: shayanghani
16+
ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:pr-${{github.run_id}}
2217

2318
jobs:
2419

@@ -28,12 +23,6 @@ jobs:
2823
- name: Checkout
2924
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
3025

31-
- name: Login to Docker Hub
32-
uses: docker/login-action@v3
33-
with:
34-
username: ${{ env.docker_hub_user }}
35-
password: ${{ secrets.DOCKER_TOKEN }}
36-
3726
- name: Login to GHCR
3827
uses: docker/login-action@v3
3928
with:
@@ -52,9 +41,7 @@ jobs:
5241
with:
5342
context: .
5443
push: true
55-
tags: |
56-
${{env.ghcr_repo_addr}}
57-
${{env.docker_repo_addr}}
44+
tags: ${{env.ghcr_repo_addr}}
5845

5946

6047

.github/workflows/dev.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI for development branches
1+
name: CI-development
22

33
on:
44
push:
@@ -26,15 +26,12 @@ on:
2626
- '.gitignore'
2727
- 'LICENSE'
2828

29-
permissions:
30-
contents: write
31-
pull-requests: read
3229

3330
env:
34-
ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest
31+
ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.action}}-${{github.run_id}}
3532

3633
jobs:
37-
probe:
34+
build-and-check:
3835
runs-on: ubuntu-latest
3936
steps:
4037
- name: Checkout

.github/workflows/release.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@ on:
1414
branches:
1515
- master
1616

17+
permissions:
18+
contents: write
19+
pull-requests: read
20+
1721
env:
1822
ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest
19-
23+
docker_repo_addr: shayanghani/container-exporter
24+
docker_hub_user: shayanghani
25+
2026
jobs:
2127
release:
28+
outputs:
29+
image_tag: ${{ steps.bump.outputs.new_tag }}
30+
2231
if: github.event_name != 'pull_request' && github.ref_name == 'master'
2332
runs-on: ubuntu-latest
2433
steps:
@@ -35,4 +44,33 @@ jobs:
3544
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
3645
with:
3746
body: ${{ steps.bump.outputs.changelog }}
38-
tag_name: ${{ steps.bump.outputs.new_tag }}
47+
tag_name: ${{ steps.bump.outputs.new_tag }}
48+
49+
docker-push:
50+
runs-on: ubuntu-latest
51+
needs: release
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
55+
56+
- name: Login to Docker Hub
57+
uses: docker/login-action@v3
58+
with:
59+
username: ${{ env.docker_hub_user }}
60+
password: ${{ secrets.DOCKER_TOKEN }}
61+
62+
- name: Set up QEMU
63+
uses: docker/setup-qemu-action@v3
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Build and Push to Dockerhub
69+
uses: docker/build-push-action@v6
70+
with:
71+
context: .
72+
push: true
73+
tags: |
74+
"${{env.docker_repo_addr}}:${{ needs.release.outputs.image_tag }}"
75+
"${{env.docker_repo_addr}}:latest"
76+

0 commit comments

Comments
 (0)