Skip to content

Commit

Permalink
Merge pull request #25 from ryu-sato/support/use-buildkit
Browse files Browse the repository at this point in the history
Support container building using BuildKit by GitHub Actions
  • Loading branch information
ryu-sato authored Mar 9, 2020
2 parents 5196f30 + e6855a7 commit 882f9e5
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true
[*]
end_of_line = lf

[*.sh]
[*.{sh,yml,yaml}]
charset = utf-8
indent_style = space
indent_size = 2
51 changes: 51 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and push Docker Image

on:
push:
branches:
- master

env:
DOCKERHUB_REPOSITORY: weseek/mongodb-awesome-backup

jobs:
build_and_push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: crazy-max/[email protected]
with:
version: v0.3.1

- name: Login to Docker Hub
run: >
echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} |
docker login --username ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin
- name: Build and push latest Docker Image
run: >
docker buildx build
--tag ${DOCKERHUB_REPOSITORY}
--platform linux/amd64
--cache-from type=registry,ref=${DOCKERHUB_REPOSITORY}
--cache-to type=inline
--push
.
publish_description:
runs-on: ubuntu-latest
needs: build_and_push

steps:
- uses: actions/checkout@v2

- name: Update Docker Hub Description
uses: peter-evans/[email protected]
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
DOCKERHUB_REPOSITORY: ${{ env.DOCKERHUB_REPOSITORY }}
README_FILEPATH: ./README.md
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
release:
types: [published]

env:
DOCKERHUB_REPOSITORY: weseek/mongodb-awesome-backup

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Get SemVer
run: |
SEMVER=`git tag | sed -E 's/^v//'`
echo ::set-env name=SEMVER::$SEMVER
- name: Set up Docker Buildx
uses: crazy-max/[email protected]
with:
version: v0.3.1

- name: Login to docker.io registry
run: >
echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} |
docker login --username ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin
- name: Build and push latest Docker Image
run: >
docker buildx build
--tag ${DOCKERHUB_REPOSITORY}
--platform linux/amd64
--cache-from type=registry,ref=${DOCKERHUB_REPOSITORY}
--cache-to type=inline
--push
.
- name: Tagging Docker Image by SemVer and publish
uses: weseek/[email protected]
with:
source: ${{ env.DOCKERHUB_REPOSITORY }}
target: ${{ env.DOCKERHUB_REPOSITORY }}
semver: ${{ env.SEMVER }}
publish: true

0 comments on commit 882f9e5

Please sign in to comment.