build: gh actions workflows for push docker image
This commit is contained in:
parent
4aa9d0808f
commit
3003876bb6
3 changed files with 94 additions and 28 deletions
62
.github/workflows/docker-push.yml
vendored
Normal file
62
.github/workflows/docker-push.yml
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
# require the secrets DOCKER_HUB_PASSWORD
|
||||
|
||||
name: Docker Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- '*'
|
||||
env:
|
||||
IMAGE_NAME: yacd
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
if [ -f docker-compose.test.yml ]; then
|
||||
docker-compose --file docker-compose.test.yml build
|
||||
docker-compose --file docker-compose.test.yml run sut
|
||||
else
|
||||
docker build . --file Dockerfile
|
||||
fi
|
||||
|
||||
push:
|
||||
needs: test
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Build image
|
||||
run: docker build . --file Dockerfile --tag image
|
||||
|
||||
- name: Log into registry
|
||||
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
IMAGE_ID=haishanh/$IMAGE_NAME
|
||||
|
||||
# Strip git ref prefix from version
|
||||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||
|
||||
# Strip "v" prefix from tag name
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||
|
||||
# Use Docker `latest` tag convention
|
||||
[ "$VERSION" == "master" ] && VERSION=latest
|
||||
|
||||
echo IMAGE_ID=$IMAGE_ID
|
||||
echo VERSION=$VERSION
|
||||
|
||||
docker tag image $IMAGE_ID:$VERSION
|
||||
docker push $IMAGE_ID:$VERSION
|
59
.github/workflows/push.yml
vendored
59
.github/workflows/push.yml
vendored
|
@ -1,4 +1,7 @@
|
|||
on: [push]
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
name: Deploy workflow
|
||||
|
||||
|
@ -11,33 +14,33 @@ jobs:
|
|||
node-version: [12.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install Lint Build
|
||||
run: |
|
||||
yarn
|
||||
yarn lint
|
||||
yarn build
|
||||
- name: Install Lint Build
|
||||
run: |
|
||||
yarn
|
||||
yarn lint
|
||||
yarn build
|
||||
|
||||
- name: Push to gh-pages
|
||||
# push only when the branch is publish
|
||||
if: github.event_name == 'push' && github.event.ref == 'refs/heads/publish'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PUBLISH_DIR: public
|
||||
BRANCH: gh-pages
|
||||
run: |
|
||||
cd $PUBLISH_DIR
|
||||
ls -l
|
||||
git init
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@noreply.github.com"
|
||||
git add .
|
||||
git status
|
||||
git commit -m "Push to gh-pages"
|
||||
git push -f https://$GITHUB_ACTOR:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
|
||||
- name: Push to gh-pages
|
||||
# push only when the branch is publish
|
||||
# if: github.event_name == 'push' && github.event.ref == 'refs/heads/publish'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PUBLISH_DIR: public
|
||||
BRANCH: gh-pages
|
||||
run: |
|
||||
cd $PUBLISH_DIR
|
||||
ls -l
|
||||
git init
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@noreply.github.com"
|
||||
git add .
|
||||
git status
|
||||
git commit -m "Push to gh-pages"
|
||||
git push -f https://$GITHUB_ACTOR:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ experimental/
|
|||
deploy_ghpages.sh
|
||||
tags
|
||||
*.log
|
||||
!.github
|
||||
|
|
Loading…
Reference in a new issue