Skip to content

Commit

Permalink
feat: 支持推送镜像到亚马逊
Browse files Browse the repository at this point in the history
  • Loading branch information
linyuan0213 committed Jun 11, 2024
1 parent 7c124ab commit 58dbd03
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: NAStool Docker

on:
workflow_dispatch:
push:
Expand All @@ -9,50 +10,55 @@ jobs:
build:
runs-on: ubuntu-latest
name: Build Docker Image

steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@master

-
name: Release version
- name: Release version
id: release_version
run: |
echo "app_version=$(echo $GITHUB_REF_NAME | sed 's/v\(.*\)/\1/')" >> $GITHUB_ENV
-
name: Set Up QEMU
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3

-
name: Set Up Buildx
- name: Set Up Buildx
uses: docker/setup-buildx-action@v3

-
name: Login DockerHub
- name: Login DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

-
name: Login GitHub Container Registry
- name: Login GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Build and Push Image
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
region: ${{ secrets.AWS_REGION }}
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Build and Push Image
uses: docker/build-push-action@v5
with:
platforms: |
linux/amd64
linux/arm64
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/nas-tools:latest
${{ secrets.DOCKER_USERNAME }}/nas-tools:${{ env.app_version }}
ghcr.io/${{ github.repository_owner }}/nas-tools:latest
ghcr.io/${{ github.repository_owner }}/nas-tools:${{ env.app_version }}
ghcr.io/${{ github.repository_owner }}/nas-tools:${{ env.app_version }}
${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_REGISTRY_ALIAS }}/nas-tools:latest
${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_REGISTRY_ALIAS }}/nas-tools:${{ env.app_version }}
- name: Logout from Amazon ECR
run: docker logout ${{ steps.login-ecr.outputs.registry }}

0 comments on commit 58dbd03

Please sign in to comment.