nezha/.github/workflows/dashboard.yml

70 lines
2.8 KiB
YAML
Raw Normal View History

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:
push:
2020-11-29 09:27:26 -05:00
branches:
- "master"
2020-11-29 09:17:40 -05:00
paths-ignore:
- "cmd/playground/**"
2020-11-29 09:17:40 -05:00
- "cmd/agent/**"
- "script/**"
- "*.md"
2021-01-29 19:57:17 -05:00
- ".*"
2021-04-28 11:37:03 -04:00
- ".github/workflows/agent.yml"
2020-11-06 07:51:23 -05:00
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
2020-11-11 09:21:16 -05:00
- name: Log into registry
2021-04-11 08:14:47 -04:00
run: |
2021-04-11 08:13:34 -04:00
echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
echo "${{ secrets.ALI_PAT }}" | docker login registry.cn-shanghai.aliyuncs.com -u ${{ secrets.ALI_USER }} --password-stdin
2021-07-07 13:54:44 -04:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Code Test
2020-11-06 07:51:23 -05:00
run: |
2021-04-03 13:28:59 -04:00
go env
2021-07-07 13:54:44 -04:00
go test -v ./...
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-07-07 14:35:23 -04:00
- name: Build dasbboard image And Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm,linux/386
push: true
tags: |
2021-07-07 14:38:35 -04:00
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}
2021-07-07 13:54:44 -04:00
2021-04-11 08:47:33 -04:00
- name: Purge jsdelivr cache
run: |
2021-04-11 09:03:34 -04:00
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/nezha-agent.service
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/docker-compose.yaml
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/config.yaml
LOWER_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/install.sh
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/nezha-agent.service
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/docker-compose.yaml
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/config.yaml