File tree Expand file tree Collapse file tree 1 file changed +50
-9
lines changed
Expand file tree Collapse file tree 1 file changed +50
-9
lines changed Original file line number Diff line number Diff line change 1- name : Docker Image CI
1+ name : Create and publish a Docker image
2+
3+ env :
4+ BUILD_PLATFORM : |
5+ linux/arm/v7
6+ linux/arm64
7+ linux/amd64
8+ REGISTRY : ghcr.io
9+ IMAGE_NAME : ${{ github.repository }}
210
311on :
412 push :
513 branches : [ "main" ]
6- pull_request :
7- branches : [ "main" ]
814
915jobs :
16+ build-and-push-image :
17+ runs-on : ubuntu-latest
18+ permissions :
19+ contents : read
20+ packages : write
21+ attestations : write
22+ id-token : write
23+
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
1027
11- build :
28+ - name : Set up QEMU
29+ uses : docker/setup-qemu-action@v3
1230
13- runs-on : ubuntu-latest
31+ - name : Set up Docker Buildx
32+ id : buildx
33+ uses : docker/setup-buildx-action@v3
1434
15- steps :
16- - uses : actions/checkout@v3
17- - name : Build the Docker image
18- run : docker build . --file Dockerfile --tag hue_exporter:$(date +%s)
35+ - name : Tag Image
36+ id : tag_image
37+ run : |
38+ DOCKER_REPOSITORY=${{ env.REGISTRY }}/${{ github.repository }}
39+ DOCKER_REPOSITORY=$(echo $DOCKER_REPOSITORY | tr '[A-Z]' '[a-z]')
40+ DOCKER_TAG=latest
41+ echo "docker_repository=${DOCKER_REPOSITORY}" >> $GITHUB_OUTPUT
42+ echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
43+
44+ - name : Log into registry
45+ uses : docker/login-action@v3
46+ with :
47+ registry : ${{ env.REGISTRY }}
48+ username : ${{ github.actor }}
49+ password : ${{ secrets.GITHUB_TOKEN }}
50+
51+ - name : Build and push Docker image
52+ uses : docker/build-push-action@v6
53+ with :
54+ context : .
55+ push : true
56+ platforms : ${{ env.BUILD_PLATFORM }}
57+ tags : |
58+ ${{ steps.tag_image.outputs.docker_repository }}:${{ steps.tag_image.outputs.docker_tag }}
59+ ${{ steps.tag_image.outputs.docker_repository }}:${{ github.sha }}
You can’t perform that action at this time.
0 commit comments