|
1 | 1 | name: Docker Push
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | push:
|
4 | 5 | branches:
|
|
11 | 12 | IMAGE_NAME: scraped2rss
|
12 | 13 |
|
13 | 14 | jobs:
|
14 |
| - # This pushes the image to GitHub Packages. |
15 | 15 | push:
|
16 | 16 | runs-on: ubuntu-latest
|
17 | 17 | permissions:
|
18 | 18 | packages: write
|
19 | 19 | contents: read
|
20 |
| - # |
| 20 | + |
21 | 21 | steps:
|
22 | 22 | - uses: actions/checkout@v4
|
23 | 23 |
|
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 |
26 | 31 |
|
| 32 | + # Login to GitHub Container Registry |
27 | 33 | - name: Log in to registry
|
28 | 34 | 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