-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
264 additions
and
521 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
name: | ||
type: string | ||
description: Name | ||
required: true | ||
image_name: | ||
type: string | ||
description: Image name. i.e. drive, dapi | ||
required: true | ||
target: | ||
type: string | ||
description: Image target. i.e. drive-abci, dapi | ||
required: true | ||
|
||
jobs: | ||
build-image: | ||
name: Build ${{ inputs.name }} ${{ matrix.platform }} image | ||
runs-on: ${{ matrix.runner }} | ||
timeout-minutes: 120 | ||
strategy: | ||
matrix: | ||
include: | ||
- runner: [ "self-hosted", "linux", "x64", "ubuntu-platform" ] | ||
platform: linux/amd64 | ||
- runner: [ "self-hosted", "linux", "x64", "ubuntu-platform" ] | ||
platform: linux/arm64 | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Configure AWS credentials and bucket region | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Get image version | ||
uses: actions/github-script@v6 | ||
id: version | ||
with: | ||
result-encoding: string | ||
script: | | ||
return ( | ||
context.eventName === 'workflow_dispatch' | ||
? '${{ github.event.inputs.tag }}' | ||
: context.payload.release.tag_name | ||
); | ||
- name: Build and push by digest | ||
uses: ./.github/actions/docker | ||
with: | ||
image_name: ${{ inputs.image_name }} | ||
image_version: ${{steps.version.outputs.result}} | ||
target: ${{ inputs.target }} | ||
cargo_profile: release | ||
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | ||
region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.docker_build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
publish-manifest: | ||
name: Publish ${{ inputs.name }} images | ||
needs: build-image | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set suffix | ||
uses: actions/github-script@v6 | ||
id: suffix | ||
with: | ||
result-encoding: string | ||
script: | | ||
const fullTag = '${{inputs.image_tag}}'; | ||
if (fullTag.includes('-')) { | ||
const [, fullSuffix] = fullTag.split('-'); | ||
const [suffix] = fullSuffix.split('.'); | ||
return `-${suffix}`; | ||
} else { | ||
return ''; | ||
} |
Oops, something went wrong.