|
1 | | -name: Build and Push Docker Image |
| 1 | +name: ci |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - tags: |
6 | | - - "*" |
7 | | - workflow_dispatch: |
8 | 5 |
|
9 | 6 | jobs: |
10 | | - build-and-push: |
| 7 | + docker: |
11 | 8 | runs-on: ubuntu-latest |
12 | | - |
13 | 9 | steps: |
14 | | - # Checkout the repository |
15 | | - - name: Checkout code |
16 | | - uses: actions/checkout@v4 |
| 10 | + - name: Login to GitHub Container Registry |
| 11 | + uses: docker/login-action@v3 |
| 12 | + with: |
| 13 | + registry: ghcr.io |
| 14 | + username: ${{ github.repository_owner }} |
| 15 | + password: ${{ secrets.GITHUB_TOKEN }} |
17 | 16 |
|
18 | | - # Get the short commit hash |
19 | | - - name: Get short commit hash |
20 | | - id: vars |
21 | | - run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 17 | + - id: image-path |
| 18 | + run: | |
| 19 | + echo "path=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT |
22 | 20 |
|
23 | | - # Log in to GitHub Docker Registry |
24 | | - - name: Log in to GitHub Docker Registry |
25 | | - run: echo "$" | docker login ghcr.io -u $ --password-stdin |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@v3 |
26 | 23 |
|
27 | | - # Build the Docker image |
28 | | - - name: Build Docker image |
29 | | - run: | |
30 | | - REPO_OWNER=$(echo "$" | tr '[:upper:]' '[:lower:]') |
31 | | - REPO_NAME=$(echo "$" | tr '[:upper:]' '[:lower:]') |
32 | | - IMAGE_TAG=$([[ "$" == "push" && "$" =~ ^refs/tags/ ]] && echo "$" || echo "$") |
33 | | - docker build . --file Dockerfile --tag ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG} |
34 | | - docker tag ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG} ghcr.io/$REPO_OWNER/$REPO_NAME:latest |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@v3 |
35 | 26 |
|
36 | | - # Push the Docker image to GitHub Container Registry |
37 | | - - name: Push Docker image |
38 | | - run: | |
39 | | - REPO_OWNER=$(echo "$" | tr '[:upper:]' '[:lower:]') |
40 | | - REPO_NAME=$(echo "$" | tr '[:upper:]' '[:lower:]') |
41 | | - IMAGE_TAG=$([[ "$" == "push" && "$" =~ ^refs/tags/ ]] && echo "$" || echo "$") |
42 | | - docker push ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG} |
43 | | - docker push ghcr.io/$REPO_OWNER/$REPO_NAME:latest |
| 27 | + - name: Build and push |
| 28 | + uses: docker/build-push-action@v6 |
| 29 | + with: |
| 30 | + platforms: linux/amd64,linux/arm64 |
| 31 | + push: true |
| 32 | + tags: | |
| 33 | + ghcr.io/${{ steps.image-path.outputs.path }}:latest |
0 commit comments