Skip to content

Build and Push to Aliyun #2

Build and Push to Aliyun

Build and Push to Aliyun #2

Workflow file for this run

name: Build and Push to Aliyun
on:
push:
branches: [ "main", "master" ]
workflow_dispatch: # 允许手动触发
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Aliyun Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.ALIYUN_REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
# 同时推送 latest 标签和基于 commit hash 的标签
tags: |
${{ secrets.ALIYUN_REGISTRY }}/${{ secrets.IMAGE_NAME }}:latest
${{ secrets.ALIYUN_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${{ github.sha }}