Build and Push to Aliyun #2
This file contains hidden or 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 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 }} |