feat: refactor docker workflow; build both amd64 and arm64 docker images
Some checks failed
Build and push Docker image / build (push) Failing after 54s
Some checks failed
Build and push Docker image / build (push) Failing after 54s
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
# Credit: https://www.vanmeeuwen.dev/blog/automating-docker-builds-with-gitea-actions
|
# Credits: https://www.vanmeeuwen.dev/blog/automating-docker-builds-with-gitea-actions
|
||||||
|
# https://gitea.com/gitea/runner-images/src/branch/main/.gitea/workflows/release.yaml
|
||||||
|
|
||||||
name: Build and push Docker image
|
name: Build and push Docker image
|
||||||
run-name: Building image on ${{ gitea.actor }}'s commit
|
run-name: Building image on ${{ gitea.actor }}'s commit
|
||||||
@@ -15,6 +16,12 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker BuildX
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -22,24 +29,26 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USER }}
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Set outputs
|
||||||
|
id: vars
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.ref_name }}
|
BRANCH_NAME: ${{ github.ref_name }}
|
||||||
SHORT_HASH: ${{ github.sha }}
|
|
||||||
run: |
|
run: |
|
||||||
# Build the image with the commit hash tag
|
echo branch_name="$BRANCH_NAME" | tee -a $GITHUB_OUTPUT
|
||||||
docker build --build-arg BUILD_IDENTIFIER=${SHORT_HASH:0:5} -t gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5} .
|
echo short_hash=$(git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT
|
||||||
|
|
||||||
# Tag the same image as "latest"
|
- name: Build and push
|
||||||
docker tag gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5} gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-latest
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
- name: Push Docker images
|
context: .
|
||||||
env:
|
platforms: |
|
||||||
BRANCH_NAME: ${{ github.ref_name }}
|
linux/amd64
|
||||||
SHORT_HASH: ${{ github.sha }}
|
linux/arm64
|
||||||
run: |
|
pull: true
|
||||||
docker push gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5}
|
push: true
|
||||||
docker push gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-latest
|
tags: |
|
||||||
|
gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-${{ steps.vars.outputs.short_hash }}
|
||||||
|
gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-latest
|
||||||
|
|
||||||
- name: Log out from registry
|
- name: Log out from registry
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user