mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-04 03:35:42 -04:00
ci: refactor dockerhub deployment process to handle both architectures in one step
This commit is contained in:
351
.github/workflows/deploy-docker-dockerhub.yml
vendored
351
.github/workflows/deploy-docker-dockerhub.yml
vendored
@@ -203,273 +203,12 @@ jobs:
|
||||
gpg_passphrase: ${{ secrets.ADMINSERV_GPG_PASSPHRASE }}
|
||||
|
||||
# #
|
||||
# Job › Docker Release › Dockerhub › Arm64
|
||||
# Job › Docker Release › Dockerhub
|
||||
# #
|
||||
|
||||
job-docker-release-dockerhub-arm64:
|
||||
job-docker-release-dockerhub:
|
||||
name: >-
|
||||
📦 Release › Dockerhub › Arm64
|
||||
# runs-on: ubuntu-latest
|
||||
runs-on: apollo-x64
|
||||
timeout-minutes: 10
|
||||
needs: [ job-docker-release-tags-create ]
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
steps:
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Start › Arm64
|
||||
# #
|
||||
|
||||
- name: '🏳️ Start'
|
||||
id: task_release_dh_start
|
||||
run: |
|
||||
echo "Starting Dockerhub arm64"
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Checkout › Amd64
|
||||
# #
|
||||
|
||||
- name: '✅ Checkout'
|
||||
id: task_release_gh_checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Get Timestamp
|
||||
# #
|
||||
|
||||
- name: '🕛 Get Timestamp'
|
||||
id: task_release_set_timestamp
|
||||
run: |
|
||||
echo "DOCKER_IMAGE=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >> ${GITHUB_ENV}
|
||||
echo "DOCKER_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
echo "NOW=$(date +'%m-%d-%Y %H:%M:%S')" >> $GITHUB_ENV
|
||||
echo "NOW_SHORT=$(date +'%m-%d-%Y')" >> $GITHUB_ENV
|
||||
echo "NOW_LONG=$(date +'%m-%d-%Y %H:%M')" >> $GITHUB_ENV
|
||||
echo "NOW_DOCKER_LABEL=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Install Dependencies
|
||||
# #
|
||||
|
||||
- name: '📦 Install Dependencies'
|
||||
id: task_release_dh_dependencies
|
||||
run:
|
||||
sudo apt-get install -qq dos2unix
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Execute dos2unix
|
||||
# #
|
||||
|
||||
- name: '🔐 Apply dos2unix'
|
||||
id: task_release_dh_dos2unix
|
||||
run: |
|
||||
echo "⚠️⚠️⚠️ Running DOS2UNIX ⚠️⚠️⚠️"
|
||||
find ./ \( -path "./.git" -o -path "./docs" -o -path "./.github" -o -path "*.png" -o -path "*.jpg" \) -prune -o -name '*' -print | xargs dos2unix --
|
||||
echo "✅✅✅ Completed DOS2UNIX ✅✅✅"
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Fix Permissions
|
||||
# #
|
||||
|
||||
- name: '#️⃣ Manage Permissions'
|
||||
id: task_release_dh_permissions
|
||||
run: |
|
||||
find ./ -name 'run' -exec chmod 755 {} \;
|
||||
WRONG_PERM=$(find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print)
|
||||
if [ -n "${WRONG_PERM}" ]; then
|
||||
echo "⚠️⚠️⚠️ Permissions are invalid ⚠️⚠️⚠️"
|
||||
for i in ${WRONG_PERM}; do
|
||||
echo "::error file=${i},line=1,title=Missing Executable Bit::This file needs to be set as executable!"
|
||||
done
|
||||
exit 1
|
||||
else
|
||||
echo "✅✅✅ Executable permissions are OK ✅✅✅"
|
||||
fi
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › QEMU › Arm64
|
||||
# #
|
||||
|
||||
- name: '⚙️ Set up QEMU'
|
||||
id: task_release_dh_qemu
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Setup BuildX › Arm64
|
||||
# #
|
||||
|
||||
- name: '⚙️ Setup Buildx'
|
||||
id: task_release_dh_buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: latest
|
||||
driver-opts: 'image=moby/buildkit:latest'
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Registry Login › Arm64
|
||||
# #
|
||||
|
||||
- name: '⚙️ Login to Dockerhub'
|
||||
id: task_release_dh_registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ env.IMAGE_DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.ORG_BINARYNINJA_DOCKERHUB_TOKEN }}
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Meta › Arm64
|
||||
# #
|
||||
|
||||
- name: '🔨 Dockerhub: Meta - Arm64'
|
||||
id: task_release_dh_meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_DOCKERHUB_AUTHOR }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
# latest no
|
||||
type=raw,value=latest,enable=false
|
||||
|
||||
# tag add arm64
|
||||
# type=raw,enable=true,priority=1000,value=arm64
|
||||
|
||||
# dispatch add x1.x.x-arm64
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=300,prefix=,suffix=-arm64,value=${{ env.IMAGE_VERSION }}
|
||||
|
||||
# dispatch add arm64-development
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == true }},priority=300,prefix=,suffix=-arm64,value=development
|
||||
|
||||
# tag add tag-arm64
|
||||
type=ref,enable=${{ github.event_name == 'pull_request' || github.event_name == 'push' }},priority=600,prefix=,suffix=-arm64,event=tag
|
||||
|
||||
flavor: |
|
||||
latest=false
|
||||
labels: |
|
||||
org.opencontainers.image.VERSION=${{ env.IMAGE_VERSION }}
|
||||
org.opencontainers.image.BUILDDATE=${{ env.NOW_DOCKER_LABEL }}
|
||||
org.opencontainers.image.licenses=MIT
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
org.opencontainers.image.vendor=${{ env.IMAGE_DOCKERHUB_AUTHOR }}
|
||||
org.opencontainers.image.ref.name=${{ env.ref_name }}
|
||||
org.opencontainers.image.development=${{ inputs.DEV_RELEASE == true && 'true' || 'false' }}
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Build and Push › Arm64
|
||||
# #
|
||||
|
||||
- name: '📦 Build & Push (linux/arm64)'
|
||||
id: task_release_dh_push
|
||||
uses: docker/build-push-action@v6
|
||||
if: ( github.event_name == 'workflow_dispatch' && inputs.DRY_RUN == false ) || ( github.event_name == 'push' )
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.aarch64
|
||||
platforms: linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.task_release_dh_meta.outputs.tags }}
|
||||
labels: ${{ steps.task_release_dh_meta.outputs.labels }}
|
||||
provenance: false
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Checkpoint › Arm64
|
||||
# #
|
||||
|
||||
- name: '⚠️ Checkpoint'
|
||||
id: task_release_dh_checkpoint
|
||||
run: |
|
||||
echo "registry ............. Dockerhub"
|
||||
echo "github.actor.......... ${{ github.actor }}"
|
||||
echo "github.ref ........... ${{ github.ref }}"
|
||||
echo "github.ref_name ...... ${{ github.ref_name }}"
|
||||
echo "github.event_name .... ${{ github.event_name }}"
|
||||
echo "inputs.DRY_RUN ....... ${{ inputs.DRY_RUN }}"
|
||||
echo "env.AUTHOR ........... ${{ env.IMAGE_DOCKERHUB_AUTHOR }}"
|
||||
echo "tags ................. ${{ steps.task_release_dh_meta.outputs.tags }}"
|
||||
echo "labels ............... ${{ steps.task_release_dh_meta.outputs.labels }}"
|
||||
echo "docker image ......... ${{ env.DOCKER_IMAGE }}"
|
||||
echo "docker sha ........... ${{ env.DOCKER_SHA }}"
|
||||
echo "docker image id ...... ${{ steps.task_release_dh_push.outputs.imageid }}"
|
||||
echo "docker digest ........ ${{ steps.task_release_dh_push.outputs.digest }}"
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Get Weekly Commits
|
||||
# #
|
||||
|
||||
- name: '🕛 Get Weekly Commit List'
|
||||
id: task_release_set_weekly_commit_list
|
||||
run: |
|
||||
echo 'WEEKLY_COMMITS<<EOF' >> $GITHUB_ENV
|
||||
git log --format="[\`%h\`](${{ github.server_url }}/${{ github.repository }}/commit/%H) %s - %an" --since=7.days >> $GITHUB_ENV
|
||||
echo 'EOF' >> $GITHUB_ENV
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Notify Github
|
||||
# #
|
||||
|
||||
- name: '🔔 Send Discord Webhook Message'
|
||||
id: task_release_notifications_discord_send
|
||||
uses: tsickert/discord-webhook@v6.0.0
|
||||
if: success()
|
||||
with:
|
||||
username: 'Io'
|
||||
avatar-url: 'https://i.imgur.com/8BVDkla.jpg'
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_CHAN_GITHUB_TVAPP2_RELEASES }}
|
||||
embed-title: "⚙️ ${{ github.workflow_ref }}"
|
||||
embed-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
embed-thumbnail-url: 'https://i.imgur.com/zDIzE8T.jpg'
|
||||
embed-description: |
|
||||
## 📦 Docker › Deploy (Dockerhub) ${{ job.status == 'success' && '✅' || '❌' }} › `${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}`
|
||||
${{ inputs.DEV_RELEASE == true && '### ⚠️⚠️ Development / Pre-release ⚠️⚠️' || '' }}
|
||||
|
||||
A new version of the docker container `${{ env.IMAGE_NAME }}` has been released from Github to Dockerhub. The image is available at:
|
||||
- https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}
|
||||
|
||||
- Release Type: `${{ inputs.DEV_RELEASE == true && '⚠️⚠️ Development / Pre-release ⚠️⚠️' || 'Stable' }}`
|
||||
- Pull: `docker pull ${{ env.DOCKER_IMAGE }}:${{ inputs.DEV_RELEASE == true && 'development' || env.IMAGE_VERSION }}-amd64`
|
||||
- Pull: `docker pull ${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push.outputs.digest }}`
|
||||
- Dry Run: `${{ inputs.DRY_RUN }}`
|
||||
- Source: `Dockerhub` https://hub.docker.com/r/${{ env.IMAGE_DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
|
||||
- Docker Image: `${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}`
|
||||
- Version: `${{ env.IMAGE_VERSION }}`
|
||||
- Branch: `${{ github.ref_name }}`
|
||||
- Workflow: `${{ github.workflow }} (#${{github.run_number}})`
|
||||
- Runner: `${{ runner.name }}`
|
||||
- Triggered By: `${{ github.actor }}`
|
||||
- Status: `${{ job.status == 'success' && '✅ Successful' || '❌ Failed' }}`
|
||||
|
||||
### Tags
|
||||
-# This docker image will use the following tags:
|
||||
|
||||
```
|
||||
${{ steps.task_release_dh_meta.outputs.tags }}
|
||||
```
|
||||
|
||||
### Labels
|
||||
-# This docker image embeds the following labels:
|
||||
|
||||
```
|
||||
${{ steps.task_release_dh_meta.outputs.labels }}
|
||||
```
|
||||
embed-color: ${{ job.status == 'success' && '5763719' || '15418782' }}
|
||||
embed-footer-text: "Completed at ${{ env.NOW }} UTC"
|
||||
embed-timestamp: "${{ env.NOW_LONG }}"
|
||||
embed-author-name: "${{ github.repository_owner }}"
|
||||
embed-author-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
embed-author-icon-url: "https://avatars.githubusercontent.com/u/200161462"
|
||||
|
||||
# #
|
||||
# Job › Docker Release › Dockerhub › Amd64
|
||||
# #
|
||||
|
||||
job-docker-release-dockerhub-amd64:
|
||||
name: >-
|
||||
📦 Release › Dockerhub › Amd64
|
||||
📦 Release › Dockerhub
|
||||
# runs-on: ubuntu-latest
|
||||
runs-on: apollo-x64
|
||||
timeout-minutes: 10
|
||||
@@ -595,17 +334,14 @@ jobs:
|
||||
# latest yes
|
||||
type=raw,value=latest,enable=${{ !inputs.DEV_RELEASE }}
|
||||
|
||||
# tag add amd64
|
||||
# type=raw,enable=true,priority=1000,value=amd64
|
||||
# dispatch add x1.x.x
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=300,prefix=,suffix=,value=${{ env.IMAGE_VERSION }}
|
||||
|
||||
# dispatch add x1.x.x-amd64
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=300,prefix=,suffix=-amd64,value=${{ env.IMAGE_VERSION }}
|
||||
# dispatch add development
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == true }},priority=300,prefix=,suffix=,value=development
|
||||
|
||||
# dispatch add amd64-development
|
||||
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == true }},priority=300,prefix=,suffix=-amd64,value=development
|
||||
|
||||
# tag add tag-arm64
|
||||
type=ref,enable=${{ github.event_name == 'pull_request' || github.event_name == 'push' }},priority=600,prefix=,suffix=-amd64,event=tag
|
||||
# tag add tag
|
||||
type=ref,enable=${{ github.event_name == 'pull_request' || github.event_name == 'push' }},priority=600,prefix=,suffix=,event=tag
|
||||
|
||||
# add development tag to default architecture (amd64)
|
||||
type=raw,enable=${{ inputs.DEV_RELEASE }},priority=400,prefix=,suffix=,value=development
|
||||
@@ -625,7 +361,7 @@ jobs:
|
||||
# #
|
||||
|
||||
- name: '📦 Build & Push (linux/amd64)'
|
||||
id: task_release_dh_push
|
||||
id: task_release_dh_push_amd64
|
||||
uses: docker/build-push-action@v6
|
||||
if: ( github.event_name == 'workflow_dispatch' && inputs.DRY_RUN == false ) || ( github.event_name == 'push' )
|
||||
with:
|
||||
@@ -636,6 +372,42 @@ jobs:
|
||||
tags: ${{ steps.task_release_dh_meta.outputs.tags }}
|
||||
labels: ${{ steps.task_release_dh_meta.outputs.labels }}
|
||||
provenance: false
|
||||
build-args: |-
|
||||
ARCH=amd64
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Build and Push › Arm64
|
||||
# #
|
||||
|
||||
- name: '📦 Build & Push (linux/arm64)'
|
||||
id: task_release_dh_push_arm64
|
||||
uses: docker/build-push-action@v6
|
||||
if: ( github.event_name == 'workflow_dispatch' && inputs.DRY_RUN == false ) || ( github.event_name == 'push' )
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
platforms: linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.task_release_dh_meta.outputs.tags }}
|
||||
labels: ${{ steps.task_release_dh_meta.outputs.labels }}
|
||||
provenance: false
|
||||
build-args: |-
|
||||
ARCH=arm64
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Push Manifest
|
||||
# #
|
||||
|
||||
- name: '📦 Push Manifest'
|
||||
id: task_release_dh_manifest
|
||||
uses: int128/docker-manifest-create-action@v2
|
||||
with:
|
||||
tags: |
|
||||
${{ inputs.DEV_RELEASE == true && 'development' || env.IMAGE_VERSION }}-amd64
|
||||
${{ inputs.DEV_RELEASE == true && 'development' || env.IMAGE_VERSION }}-arm64
|
||||
sources: |
|
||||
${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push_amd64.outputs.digest }}
|
||||
${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push_arm64.outputs.digest }}
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Checkpoint › Amd64
|
||||
@@ -644,19 +416,21 @@ jobs:
|
||||
- name: '⚠️ Checkpoint'
|
||||
id: task_release_dh_checkpoint
|
||||
run: |
|
||||
echo "registry ............. Dockerhub"
|
||||
echo "github.actor.......... ${{ github.actor }}"
|
||||
echo "github.ref ........... ${{ github.ref }}"
|
||||
echo "github.ref_name ...... ${{ github.ref_name }}"
|
||||
echo "github.event_name .... ${{ github.event_name }}"
|
||||
echo "inputs.DRY_RUN ....... ${{ inputs.DRY_RUN }}"
|
||||
echo "env.AUTHOR ........... ${{ env.IMAGE_DOCKERHUB_AUTHOR }}"
|
||||
echo "tags ................. ${{ steps.task_release_dh_meta.outputs.tags }}"
|
||||
echo "labels ............... ${{ steps.task_release_dh_meta.outputs.labels }}"
|
||||
echo "docker image ......... ${{ env.DOCKER_IMAGE }}"
|
||||
echo "docker sha ........... ${{ env.DOCKER_SHA }}"
|
||||
echo "docker image id ...... ${{ steps.task_release_dh_push.outputs.imageid }}"
|
||||
echo "docker digest ........ ${{ steps.task_release_dh_push.outputs.digest }}"
|
||||
echo "registry ..................... Dockerhub"
|
||||
echo "github.actor.................. ${{ github.actor }}"
|
||||
echo "github.ref ................... ${{ github.ref }}"
|
||||
echo "github.ref_name .............. ${{ github.ref_name }}"
|
||||
echo "github.event_name ............ ${{ github.event_name }}"
|
||||
echo "inputs.DRY_RUN ............... ${{ inputs.DRY_RUN }}"
|
||||
echo "env.AUTHOR ................... ${{ env.IMAGE_DOCKERHUB_AUTHOR }}"
|
||||
echo "tags ......................... ${{ steps.task_release_dh_meta.outputs.tags }}"
|
||||
echo "labels ....................... ${{ steps.task_release_dh_meta.outputs.labels }}"
|
||||
echo "docker image ................. ${{ env.DOCKER_IMAGE }}"
|
||||
echo "docker sha ................... ${{ env.DOCKER_SHA }}"
|
||||
echo "docker image id (amd64) ...... ${{ steps.task_release_dh_push_amd64.outputs.imageid }}"
|
||||
echo "docker digest (amd64) ........ ${{ steps.task_release_dh_push_amd64.outputs.digest }}"
|
||||
echo "docker image id (arm64) ...... ${{ steps.task_release_dh_push_arm64.outputs.imageid }}"
|
||||
echo "docker digest (arm64) ........ ${{ steps.task_release_dh_push_arm64.outputs.digest }}"
|
||||
|
||||
# #
|
||||
# Release › Dockerhub › Get Weekly Commits
|
||||
@@ -692,7 +466,8 @@ jobs:
|
||||
|
||||
- Release Type: `${{ inputs.DEV_RELEASE == true && '⚠️⚠️ Development / Pre-release ⚠️⚠️' || 'Stable' }}`
|
||||
- Pull: `docker pull ${{ env.DOCKER_IMAGE }}:${{ inputs.DEV_RELEASE == true && 'development' || env.IMAGE_VERSION }}-amd64`
|
||||
- Pull: `docker pull ${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push.outputs.digest }}`
|
||||
- Pull (amd64): `docker pull ${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push_amd64.outputs.digest }}`
|
||||
- Pull (arm64): `docker pull ${{ env.DOCKER_IMAGE }}@${{ steps.task_release_dh_push_arm64.outputs.digest }}`
|
||||
- Dry Run: `${{ inputs.DRY_RUN }}`
|
||||
- Source: `Dockerhub` https://hub.docker.com/r/${{ env.IMAGE_DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
|
||||
- Docker Image: `${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}`
|
||||
|
||||
Reference in New Issue
Block a user