Push Docker image to DockerHub

This commit is contained in:
CrazyMax 2019-09-02 17:51:26 +02:00
parent 434fb87ce4
commit 4b688551c8
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 62 additions and 2 deletions

45
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: docker
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- v*
jobs:
release:
runs-on: ubuntu-latest
steps:
-
name: Set TAG_NAME
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "##[set-env name=TAG_NAME;]${GITHUB_REF#refs/tags/}"
-
name: Checkout
uses: actions/checkout@v1
-
name: Docker Build
run: |
docker build \
--build-arg "VERSION=${TAG_NAME}" \
--tag "crazymax/ghaction-github-pages:${TAG_NAME}" \
--tag "crazymax/ghaction-github-pages:latest" \
--file Dockerfile .
-
name: Docker Login
if: success() && startsWith(github.ref, 'refs/tags/v')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
-
name: Docker Push
if: success() && startsWith(github.ref, 'refs/tags/v')
run: |
docker push crazymax/ghaction-github-pages

View File

@ -1,13 +1,15 @@
FROM alpine/git:latest FROM alpine/git:latest
ARG VERSION
# https://help.github.com/en/articles/metadata-syntax-for-github-actions#about-yaml-syntax-for-github-actions # https://help.github.com/en/articles/metadata-syntax-for-github-actions#about-yaml-syntax-for-github-actions
LABEL version="0.1.0" \ LABEL version="$VERSION" \
repository="https://github.com/crazy-max/ghaction-github-pages" \ repository="https://github.com/crazy-max/ghaction-github-pages" \
homepage="https://github.com/crazy-max/ghaction-github-pages" \ homepage="https://github.com/crazy-max/ghaction-github-pages" \
maintainer="CrazyMax" \ maintainer="CrazyMax" \
"com.github.actions.name"="GitHub Pages" \ "com.github.actions.name"="GitHub Pages" \
"com.github.actions.description"="GitHub Action for deploying GitHub Pages" \ "com.github.actions.description"="GitHub Action for deploying GitHub Pages" \
"com.github.actions.icon"="package" \ "com.github.actions.icon"="upload-cloud" \
"com.github.actions.color"="green" "com.github.actions.color"="green"
COPY LICENSE README.md / COPY LICENSE README.md /

View File

@ -52,6 +52,19 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
Docker :whale: image is also provided and automatically updated within [Docker Hub](https://hub.docker.com/u/crazymax/ghaction-github-pages) so you can directly use the following [DockerHub action](https://help.github.com/en/articles/workflow-syntax-for-github-actions#example-using-a-docker-hub-action):
```yaml
- name: Deploy
if: success()
uses: docker://crazymax/ghaction-github-pages
with:
target_branch: gh-pages
build_dir: public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
## 💅 Customizing ## 💅 Customizing
### inputs ### inputs