Skip to content

Commit 40de115

Browse files
committed
upload images on gihub packages showing the branch origin
1 parent 4b138bd commit 40de115

File tree

1 file changed

+58
-10
lines changed

1 file changed

+58
-10
lines changed

.github/workflows/build-base-image.yml

+58-10
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,73 @@ on:
99

1010
jobs:
1111
push_to_registry:
12-
name: Build and Push to DockerHub Registry
12+
name: Build and Push Docker Image
1313
runs-on: ubuntu-latest
14-
14+
strategy:
15+
matrix:
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
permissions:
18+
contents: read
19+
packages: write
20+
id-token: write
1521
steps:
1622
- name: Checkout
17-
uses: actions/checkout@v2
18-
19-
- name: Log in to Docker Hub
20-
uses: docker/login-action@v1
23+
uses: actions/checkout@v4
2124
with:
22-
username: ${{ secrets.DOCKER_USERNAME }}
23-
password: ${{ secrets.DOCKER_PASSWORD }}
25+
fetch-depth: 0
2426

27+
- name: Login to Github Packages
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract Docker Metadata
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
flavor: |
39+
suffix=-${{ matrix.python-version }}
40+
tags: |
41+
type=ref,event=branch
42+
type=raw,value=${{ github.ref_name }}
43+
type=raw,value=latest,suffix=,enable=${{ github.ref_name == github.event.repository.default_branch }}
44+
images: |
45+
name=${{ secrets.DOCKER_USERNAME }}/python-base-eval-layer,enable=false
46+
name=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
47+
2548
- name: Build and Push Base Image
26-
uses: docker/build-push-action@v2
49+
uses: docker/build-push-action@v5
2750
with:
2851
push: true
29-
tags: ${{ secrets.DOCKER_USERNAME }}/python-base-eval-layer
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
3054
build-args: |
55+
PYTHON_VERSION=${{ matrix.python-version }}
3156
INVOKER_ID=${{ secrets.INVOKER_ID }}
3257
INVOKER_KEY=${{ secrets.INVOKER_KEY }}
3358
INVOKER_REGION=${{ secrets.INVOKER_REGION }}
59+
60+
# name: Build and Push to DockerHub Registry
61+
# runs-on: ubuntu-latest
62+
63+
# steps:
64+
# - name: Checkout
65+
# uses: actions/checkout@v2
66+
67+
# - name: Log in to Docker Hub
68+
# uses: docker/login-action@v1
69+
# with:
70+
# username: ${{ secrets.DOCKER_USERNAME }}
71+
# password: ${{ secrets.DOCKER_PASSWORD }}
72+
73+
# - name: Build and Push Base Image
74+
# uses: docker/build-push-action@v2
75+
# with:
76+
# push: true
77+
# tags: ${{ secrets.DOCKER_USERNAME }}/python-base-eval-layer
78+
# build-args: |
79+
# INVOKER_ID=${{ secrets.INVOKER_ID }}
80+
# INVOKER_KEY=${{ secrets.INVOKER_KEY }}
81+
# INVOKER_REGION=${{ secrets.INVOKER_REGION }}

0 commit comments

Comments
 (0)