Skip to content

Commit

Permalink
Merge pull request #55 from stack-wuh/feat-ci
Browse files Browse the repository at this point in the history
fix: (ci) 测试自动重启容器脚本错误
  • Loading branch information
stack-wuh committed Dec 12, 2021
2 parents da7567e + 9d71f23 commit e1f39d9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 61 deletions.
107 changes: 49 additions & 58 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,46 @@ on:
types: [published]

jobs:
# push_to_docker:
# name: Push Docker image to Docker Hub
# runs-on: ubuntu-latest
# outputs:
# tags: ${{ steps.release_head_tags.outputs.tags }}
# steps:
# - name: Check out the repo
# uses: actions/checkout@v2
push_to_docker:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.release_head_tags.outputs.tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

# - name: Log in to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v3
# with:
# images: shadowu/wuh.site
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: shadowu/wuh.site

# - name: Build and push Docker image
# uses: docker/build-push-action@v2
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# - name: Output
# id: release_head_tags
# run: echo "::set-output name=tags::${{ steps.meta.outputs.tags }}"
- name: Output
id: release_head_tags
run: echo "::set-output name=tags::${{ steps.meta.outputs.tags }}"

# build_container:
# name: Build Container
# runs-on: ubuntu-latest
# needs: [push_to_docker]
# env:
# TAG_REF: ${{ github.ref }}
# GITHUB_CONTEXT: ${{ toJson(github) }}
# steps:
# - name: executing remote ssh commands using password
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }}
# key: ${{ secrets.KEY }}
# port: ${{ secrets.PORT }}
# script: |
# docker ps -a
# tag=`echo ${TAG_REF}|awk -F/ '{print $3}'`
# echo "[github bot] version:" ${tag}
# echo ${TAG_REF}
# echo "$GITHUB_CONTEXT"
# cd /home/next-web-app/frontend
# ./bin/clear-docker.sh
# ./bin/build-container.sh ${tag} hello world

test_build:
name: test build
build_container:
name: Build Container
runs-on: ubuntu-latest
needs: [push_to_docker]
env:
TAG_REF: ${{ github.ref }}
GITHUB_CONTEXT: ${{ toJson(github) }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -81,6 +60,18 @@ jobs:
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: latest
- name: logger
run: |
echo "version.tag:" ${{ steps.previoustag.outputs.tag }}
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
docker ps -a
echo "[github bot] version:" ${{ steps.previoustag.outputs.tag }}
echo ${TAG_REF}
echo "$GITHUB_CONTEXT"
cd /home/next-web-app/frontend
./bin/clear-docker.sh
./bin/build-container.sh ${{ steps.previoustag.outputs.tag }} hello world
4 changes: 1 addition & 3 deletions bin/build-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

set -e

git reset --hard HEAD~~
git pull origin main

VERSION=$(jq -r '.version' package.json)

echo '全部参数:' $@
echo 'version:' $0

echo '============== docker build contianer ==========='
echo '构建container的版本号: ' $VERSION
Expand Down

2 comments on commit e1f39d9

@vercel
Copy link

@vercel vercel bot commented on e1f39d9 Dec 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

The most recent charge for your active payment method has failed. Please update it here: https://vercel.com/teams/163m/settings/billing.

@vercel
Copy link

@vercel vercel bot commented on e1f39d9 Dec 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.