feat: host change #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-amd64: | |
| runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare repository name | |
| id: repo | |
| run: echo "name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Build and push (AMD64) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64 | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/${{ steps.repo.outputs.name }}:latest-amd | |
| ghcr.io/${{ steps.repo.outputs.name }}:${{ github.sha }}-amd | |
| build-arm64: | |
| runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare repository name | |
| id: repo | |
| run: echo "name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Build and push (ARM64) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/arm64 | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/${{ steps.repo.outputs.name }}:latest-arm | |
| ghcr.io/${{ steps.repo.outputs.name }}:${{ github.sha }}-arm | |
| build-merge: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-amd64 | |
| - build-arm64 | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare repository name | |
| id: repo | |
| run: echo "name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Merge | |
| run: | | |
| docker buildx imagetools create -t ghcr.io/${{ steps.repo.outputs.name }}:latest \ | |
| ghcr.io/${{ steps.repo.outputs.name }}:latest-amd \ | |
| ghcr.io/${{ steps.repo.outputs.name }}:latest-arm |