Skip to content

Commit dd55fa7

Browse files
authored
Update docker-image.yml
1 parent 4010668 commit dd55fa7

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

.github/workflows/docker-image.yml

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Docker Push
2+
23
on:
34
push:
45
branches:
@@ -11,35 +12,37 @@ env:
1112
IMAGE_NAME: scraped2rss
1213

1314
jobs:
14-
# This pushes the image to GitHub Packages.
1515
push:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
packages: write
1919
contents: read
20-
#
20+
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- name: Build image
25-
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
24+
# Set up QEMU
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v1
27+
28+
# Set up Docker Buildx
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v1
2631

32+
# Login to GitHub Container Registry
2733
- name: Log in to registry
2834
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
29-
#
30-
- name: Push image
31-
run: |
32-
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
33-
34-
# This changes all uppercase characters to lowercase.
35-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
36-
# This strips the git ref prefix from the version.
37-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
38-
# This strips the "v" prefix from the tag name.
39-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
40-
# This uses the Docker `latest` tag convention.
41-
[ "$VERSION" == "main" ] && VERSION=latest
42-
echo IMAGE_ID=$IMAGE_ID
43-
echo VERSION=$VERSION
44-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
45-
docker push $IMAGE_ID:$VERSION
35+
36+
# Build and Push Docker image for multiple platforms
37+
- name: Build and push
38+
uses: docker/build-push-action@v2
39+
with:
40+
context: .
41+
file: ./Dockerfile
42+
push: true
43+
tags: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
44+
build-args: |
45+
runnumber=${GITHUB_RUN_ID}
46+
platforms: linux/amd64,linux/arm64 # Specify platforms here
47+
48+
# Additional steps can be added if needed

0 commit comments

Comments
 (0)