Skip to content

Commit

Permalink
Add setup-docker (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored Oct 4, 2021
1 parent 524d78d commit 4496211
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ci
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"

permissions:
contents: read

jobs:
setup-docker:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- uses: ./setup-docker
- run: docker version
- run: docker compose version
- run: docker buildx version
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,58 @@ A collection of composite run steps GitHub Actions.


## Setup Docker Project

This composite action includes the following actions:

- Install docker compose v2
- Install docker buildx

Definition: [setup-docker/action.yml](https://github.com/peaceiris/workflows/blob/main/setup-docker/action.yml)

### Install the Latest Version

```yaml
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: peaceiris/workflows/[email protected]
- run: docker compose version
- run: docker buildx version
```
### Install a Specific Version
```yaml
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: peaceiris/workflows/[email protected]
with:
compose-version: '2.0.1'
buildx-version: '0.6.3'
- run: docker compose version
- run: docker buildx version
```
## Setup Go Project
This composite action includes the following actions:
Expand Down
49 changes: 49 additions & 0 deletions setup-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Setup Docker'
description: 'A composite action to setup Docker project.'
inputs:
compose-version:
description: 'Set a compose version (>= 2.0.0), e.g. 2.0.1'
default: 'latest'
required: false
buildx-version:
description: 'Set a buildx version, e.g. 0.6.3'
default: 'latest'
required: false
runs:
using: "composite"
steps:
- name: Prepare .docker
shell: bash
run: |
mkdir -p "${HOME}/.docker/cli-plugins"
- run: docker version
shell: bash

- name: Install docker compose
shell: bash
run: |
if [ "${{ inputs.compose-version }}" = "latest" ]; then
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')
else
COMPOSE_VERSION="${{ inputs.compose-version }}"
fi
curl --silent -L "https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION#v}/docker-compose-$(uname -s)-$(uname -m)" \
-o "${HOME}/.docker/cli-plugins/docker-compose"
chmod a+x "${HOME}/.docker/cli-plugins/docker-compose"
- run: docker compose version
shell: bash

- name: Install docker buildx
shell: bash
run: |
if [ "${{ inputs.buildx-version }}" = "latest" ]; then
BUILDX_VERSION=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.tag_name')
else
BUILDX_VERSION="${{ inputs.buildx-version }}"
fi
curl --silent -L "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION#v}/buildx-v${BUILDX_VERSION#v}.linux-amd64" \
-o "${HOME}/.docker/cli-plugins/docker-buildx"
chmod a+x "${HOME}/.docker/cli-plugins/docker-buildx"
- run: docker buildx version
shell: bash

0 comments on commit 4496211

Please sign in to comment.