-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ub/workflows/build-and-release-image.yaml → .github/workflows/build-publish-latest.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build and publish docker image | ||
name: Build Latest Image | ||
|
||
on: | ||
push: | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Release Image | ||
on: | ||
#防止fork乱用action设置只能手动触发构建 | ||
workflow_dispatch: | ||
## 发布release的时候会自动构建 | ||
release: | ||
types: [published] | ||
jobs: | ||
publish-docker-image: | ||
runs-on: ubuntu-latest | ||
name: Build image | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: judge has env GITHUB_REF # 如果没有GITHUB_REF环境变量,则把github.ref变量赋值给GITHUB_REF | ||
run: | | ||
if [ -z "$GITHUB_REF" ]; then | ||
export GITHUB_REF=${{ github.ref }} | ||
fi | ||
- name: Check GITHUB_REF env | ||
run: echo $GITHUB_REF | ||
- name: Get version | ||
id: get_version | ||
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/free-one-api') | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
- name: Build # image name: rockchin/free-one-api:<VERSION> | ||
run: docker build --network=host -t rockchin/free-one-api:${{ steps.get_version.outputs.VERSION }} . | ||
- name: Login to Registry | ||
run: docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Push release image | ||
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/free-one-api') | ||
run: docker push rockchin/free-one-api:${{ steps.get_version.outputs.VERSION }} |