chore: docker build #20
This file contains 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: Publish Docker Image | |
on: | |
push: | |
branches: [master] | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
amd64_build: | |
name: Build AMD64 Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Build and export | |
id: build | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
context: scripts/ | |
tags: ghcr.io/metacubex/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
outputs: type=image,push=true | |
- name: Save digest | |
if: github.ref == 'refs/heads/master' | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_amd64 | |
path: /tmp/digest.txt | |
x86_build: | |
name: Build x86 Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Build and export | |
id: build | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/386 | |
context: scripts/ | |
tags: ghcr.io/metacubex/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
outputs: type=image,push=true | |
- name: Save digest | |
if: github.ref == 'refs/heads/master' | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_386 | |
path: /tmp/digest.txt | |
arm64_build: | |
name: Build ARM64 Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Build and export | |
id: build | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/arm64 | |
context: scripts/ | |
tags: ghcr.io/metacubex/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
THREADS=2 | |
outputs: type=image,push=true | |
- name: Save digest | |
if: github.ref == 'refs/heads/master' | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_arm64 | |
path: /tmp/digest.txt | |
build: | |
name: Build | |
needs: [amd64_build, x86_build, arm64_build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
config-inline: | | |
[worker.oci] | |
max-parallelism = 1 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/images/ | |
- name: login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Merge and push manifest on master branch | |
if: github.ref == 'refs/heads/master' | |
run: python scripts/merge_manifest.py |