2020-11-29 09:23:00 -05:00
|
|
|
name: Dashboard image
|
2020-11-06 07:51:23 -05:00
|
|
|
|
2020-11-29 09:17:40 -05:00
|
|
|
on:
|
2021-09-04 00:51:02 -04:00
|
|
|
workflow_run:
|
|
|
|
workflows: ["Run Tests"]
|
|
|
|
branches: [master]
|
2021-11-03 09:40:22 -04:00
|
|
|
types:
|
2021-09-04 00:51:02 -04:00
|
|
|
- completed
|
2022-06-07 09:42:53 -04:00
|
|
|
workflow_dispatch:
|
2020-11-06 07:51:23 -05:00
|
|
|
|
|
|
|
jobs:
|
2021-11-03 09:40:22 -04:00
|
|
|
on-success:
|
2022-06-07 09:50:18 -04:00
|
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
|
2020-11-06 07:51:23 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@master
|
2020-11-11 09:21:16 -05:00
|
|
|
|
2022-07-06 22:27:14 -04:00
|
|
|
- name: Extract branch name
|
|
|
|
run: |
|
|
|
|
export BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
|
|
|
|
echo "##[set-output name=branch;]$BRANCH_NAME"
|
|
|
|
if [ $BRANCH_NAME = "main" ] || [ $BRANCH_NAME = "master" ]
|
|
|
|
then echo "##[set-output name=tag;]latest"
|
|
|
|
else echo "##[set-output name=tag;]$BRANCH_NAME"
|
|
|
|
fi
|
|
|
|
id: extract_branch
|
|
|
|
|
2022-07-06 23:50:25 -04:00
|
|
|
- name: xgo build
|
2022-07-06 23:21:54 -04:00
|
|
|
uses: crazy-max/ghaction-xgo@v2
|
|
|
|
with:
|
|
|
|
xgo_version: latest
|
|
|
|
go_version: 1.18
|
2022-07-06 23:50:25 -04:00
|
|
|
dest: dist
|
2022-07-06 23:21:54 -04:00
|
|
|
pkg: cmd/dashboard
|
|
|
|
prefix: dashboard
|
2022-07-07 01:38:44 -04:00
|
|
|
targets: linux/amd64,linux/arm64,linux/arm-7,linux/386,linux/s390x,linux/riscv64
|
2022-07-06 23:21:54 -04:00
|
|
|
v: true
|
|
|
|
x: false
|
|
|
|
race: false
|
|
|
|
ldflags: -s -w
|
|
|
|
buildmode: default
|
2022-07-06 22:27:14 -04:00
|
|
|
|
2022-07-07 01:38:44 -04:00
|
|
|
- name: fix dist
|
2022-07-06 22:27:14 -04:00
|
|
|
run: |
|
2022-07-07 01:38:44 -04:00
|
|
|
cp dist/dashboard-linux-arm-7 dist/dashboard-linux-arm
|
2022-07-06 22:27:14 -04:00
|
|
|
|
2021-08-18 06:53:35 -04:00
|
|
|
- name: Log in to the GHCR
|
|
|
|
uses: docker/login-action@master
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Log in to the AliyunCS
|
|
|
|
uses: docker/login-action@master
|
|
|
|
with:
|
|
|
|
registry: registry.cn-shanghai.aliyuncs.com
|
|
|
|
username: ${{ secrets.ALI_USER }}
|
|
|
|
password: ${{ secrets.ALI_PAT }}
|
2021-09-04 00:18:12 -04:00
|
|
|
|
2021-07-07 13:54:44 -04:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2021-09-04 00:18:12 -04:00
|
|
|
|
2021-07-07 13:54:44 -04:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
2021-09-04 00:18:12 -04:00
|
|
|
|
2021-07-07 14:35:23 -04:00
|
|
|
- name: Set up image name
|
2021-04-11 08:13:34 -04:00
|
|
|
run: |
|
|
|
|
GHRC_IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
2021-04-11 09:59:33 -04:00
|
|
|
if [ ${{ github.repository_owner }} = "naiba" ]
|
2021-07-07 14:35:23 -04:00
|
|
|
then ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard")
|
|
|
|
else ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
2021-04-11 09:59:33 -04:00
|
|
|
fi
|
2021-07-07 14:38:35 -04:00
|
|
|
echo "::set-output name=GHRC_IMAGE_NAME::$GHRC_IMAGE_NAME"
|
|
|
|
echo "::set-output name=ALI_IMAGE_NAME::$ALI_IMAGE_NAME"
|
|
|
|
id: image-name
|
2021-09-04 00:18:12 -04:00
|
|
|
|
2021-07-07 14:35:23 -04:00
|
|
|
- name: Build dasbboard image And Push
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
2022-07-07 01:38:44 -04:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm,linux/386,linux/s390x,linux/riscv64
|
2021-07-07 14:35:23 -04:00
|
|
|
push: true
|
|
|
|
tags: |
|
2022-07-06 22:27:14 -04:00
|
|
|
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
|
|
|
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|