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
|
7
.github/workflows/push.yml
vendored
7
.github/workflows/push.yml
vendored
|
@ -1,4 +1,7 @@
|
|||
on: [push]
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
name: Deploy workflow
|
||||
|
||||
|
@ -26,7 +29,7 @@ jobs:
|
|||
|
||||
- name: Push to gh-pages
|
||||
# push only when the branch is publish
|
||||
if: github.event_name == 'push' && github.event.ref == 'refs/heads/publish'
|
||||
# if: github.event_name == 'push' && github.event.ref == 'refs/heads/publish'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PUBLISH_DIR: public
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ experimental/
|
|||
deploy_ghpages.sh
|
||||
tags
|
||||
*.log
|
||||
!.github
|
||||
|
|
Loading…
Reference in a new issue