Skip to content

Update ci.yml

Update ci.yml #112

Workflow file for this run

name: CI
on:
push:
branches:
- master
jobs:
setup:
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.set_timestamp.outputs.timestamp }}
steps:
- name: Set timestamp
id: set_timestamp
run: |
TIMESTAMP=$(TZ=Asia/Shanghai date +%Y-%m-%d.%H-%M-%S)
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
arch:
- amd64
- arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Aliyun Hub
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.OPSRE_ALIHUB_USERNAME }}
password: ${{ secrets.OPSRE_ALIHUB_TOKEN }}
- name: Set env variables
id: set_env
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "SHORT_SHA=${GITHUB_SHA:0:4}" >> $GITHUB_ENV
echo "DATE=${{ needs.setup.outputs.timestamp }}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
VERSION=${{ env.DATE }}
TARGETARCH=${{ matrix.arch }}
tags: |
cairry/watchalert:latest
cairry/watchalert:${{ env.BRANCH_NAME }}.${{ env.DATE }}.${{ env.SHORT_SHA }}
registry.cn-hangzhou.aliyuncs.com/opsre/watchalert:latest
registry.cn-hangzhou.aliyuncs.com/opsre/watchalert:${{ env.BRANCH_NAME }}.${{ env.DATE }}.${{ env.SHORT_SHA }}