浏览代码

fix: upgrade github actions

jeessy2 3 年之前
父节点
当前提交
43c2377d81
共有 2 个文件被更改,包括 20 次插入24 次删除
  1. 18 22
      .github/workflows/docker-image.yml
  2. 2 2
      .github/workflows/release.yml

+ 18 - 22
.github/workflows/docker-image.yml

@@ -13,32 +13,28 @@ jobs:
     runs-on: ubuntu-latest
     env:
       DOCKER_REPO: jeessy/backup-x
-      DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
-      DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
       DOCKER_PLATFORMS: linux/amd64,linux/arm,linux/arm64
-      DOCKER_REGISTRY: ""
     steps:
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
       - name: Set up Docker buildx
-        id: buildx
-        uses: crazy-max/ghaction-docker-buildx@v3
+        uses: docker/setup-buildx-action@v1
       - name: Prepare arguments
-        id: prepare
         run: |
-          DOCKER_TAGS="--tag ${DOCKER_REPO}:edge"
-          if [[ $GITHUB_REF == refs/tags/v* ]]; then
-            DOCKER_TAGS="--tag ${DOCKER_REPO}:latest --tag ${DOCKER_REPO}:${GITHUB_REF#refs/tags/}"
-          fi
-          echo ::set-output name=buildx_args:: --output "type=image,push=true" --platform ${DOCKER_PLATFORMS} ${DOCKER_TAGS} .
-      - name: Docker login
-        run: |
-          echo "${DOCKER_PASSWORD}" | docker login "${DOCKER_REGISTRY}"  \
-            --username "${DOCKER_USERNAME}" \
-            --password-stdin
+          echo "VERSION=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
+      - name: Docker login # login to docker hub, automatically logout at the end of job
+        uses: docker/login-action@v1 
+        with:
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PASSWORD }}
       - name: Run buildx and push
-        if: success()
-        run: docker buildx build ${{ steps.prepare.outputs.buildx_args }}
-      - name: Docker Hub logout
-        if: always()
-        run: docker logout
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          push: true # push to docker hub
+          platforms: ${{ env.DOCKER_PLATFORMS }}
+          tags: |
+            ${{ env.DOCKER_REPO }}:latest
+            ${{ env.DOCKER_REPO }}:${{ env.VERSION }}

+ 2 - 2
.github/workflows/release.yml

@@ -12,12 +12,12 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           fetch-depth: 0
 
       - name: Set up Go
-        uses: actions/setup-go@v2
+        uses: actions/setup-go@v3
         with:
           go-version: 1.17