@@ -3,15 +3,15 @@ name: Docker Build and Publish
33on :
44 push :
55 branches :
6- - main # Or your default branch, e.g., master
6+ - master # Or your default branch, e.g., master
77 pull_request :
88 branches :
9- - main # Or your default branch
9+ - master # Or your default branch
10+ workflow_dispatch :
1011
1112jobs :
1213 build-and-push-image :
1314 # Only run this job on pushes to the main branch
14- if : github.event_name == 'push' && github.ref == 'refs/heads/main' # Adjust 'main' if your default branch is different
1515 runs-on : ubuntu-latest
1616 permissions :
1717 contents : read
2121 - name : Checkout repository
2222 uses : actions/checkout@v4
2323
24+ - name : Set up Docker Buildx
25+ uses : docker/setup-buildx-action@v3
26+ with :
27+ version : latest
28+
2429 - name : Log in to GitHub Container Registry
2530 uses : docker/login-action@v3
2631 with :
@@ -38,40 +43,12 @@ jobs:
3843 type=raw,value=latest,enable={{is_default_branch}}
3944
4045 - name : Build and push Docker image
41- uses : docker/build-push-action@v5
46+ uses : docker/build-push-action@v6
4247 with :
4348 context : .
44- push : true
45- tags : ${{ steps.meta.outputs.tags }}
49+ tags : ghcr.io/aosus/link-chain:latest
50+ platforms : linux/amd64, linux/arm64/v8
51+ push : ${{ github.event_name != 'pull_request' }}
4652 labels : ${{ steps.meta.outputs.labels }}
47-
48- build-for-pr :
49- # Only run this job on pull requests
50- if : github.event_name == 'pull_request'
51- runs-on : ubuntu-latest
52- permissions :
53- contents : read # Only need to read the repo content
54-
55- steps :
56- - name : Checkout repository
57- uses : actions/checkout@v4
58-
59- - name : Build Docker image (no push)
60- uses : docker/build-push-action@v5
61- with :
62- context : .
63- push : false # Just build, don't push
64- # No need for tags or labels here as we are not pushing
65- # Optionally, you can load it to docker to run tests if you have them
66- # load: true
67-
68- # Example of a simple test: check if the bot script can be executed with --help
69- # This is a very basic test and might need adjustment based on your bot's CLI
70- # - name: Run a basic container health check (example)
71- # if: steps.docker_build.outputs.digest != '' # Only if build succeeded
72- # run: |
73- # docker run --rm ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} python matrix_bot.py --help
74- # # Note: The tag above might not be available if not loaded.
75- # # If using load:true in build step, you can use a simpler image name.
76- # # This step is illustrative; actual testing would depend on the bot's capabilities.
77- # echo "Container build successful. Further runtime tests would go here if applicable."
53+ cache-from : type=gha
54+ cache-to : type=gha,mode=max
0 commit comments