Build docker image #29
Workflow file for this run
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: Build docker image | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
dispatch: | |
type: string | |
description: "The tag name for docker images" | |
required: true | |
jobs: | |
output_tag_name: | |
runs-on: ubuntu-22.04 | |
outputs: | |
tag_name: ${{ steps.output.outputs.tag_name }} | |
steps: | |
- name: output tag name for image | |
id: output | |
run: | | |
if [ ${{ github.event_name }} == 'push' ]; then | |
export tag_name=`echo ${{ github.ref }} | awk -F '/' '{print $3}'` | |
fi | |
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then | |
export tag_name=${{ github.event.inputs.dispatch }} | |
fi | |
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT | |
build-amd64-image: | |
runs-on: ubuntu-22.04 | |
needs: output_tag_name | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref || 'main' }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: axonweb3/axon:amd64-${{ needs.output_tag_name.outputs.tag_name }} | |
build-arm64-image: | |
runs-on: [self-hosted, build] | |
needs: output_tag_name | |
env: | |
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} | |
AWS_EC2_TYPE: "c6g.xlarge" | |
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
AXON_TAG: arm64-${{needs.output_tag_name.outputs.tag_name}} | |
steps: | |
- name: Get Current Date & Set ENV | |
id: date | |
run: | | |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref || 'build-arm64-image' }} | |
- name: arm64 docker image build | |
env: | |
JOB_ID: "build-arm64-image-${{ github.repository_owner }}-${{ steps.date.outputs.date }}-in-10h" | |
run: | | |
./devtools/ci/build-arm64.sh run | |
- name: clean up | |
if: ${{ always() }} | |
env: | |
JOB_ID: "build-arm64-image-${{ github.repository_owner }}-${{ steps.date.outputs.date }}-in-10h" | |
run: | | |
./devtools/ci/build-arm64.sh clean |