-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add docker images to GitHub Actions
- Loading branch information
Showing
5 changed files
with
133 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: docker-images | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
DOCKERHUB_USERNAME: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
docker-images: | ||
name: Publish docker images | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
helm: | ||
- 2.17.0 | ||
- 3.8.2 | ||
- 3.9.3 | ||
env: | ||
IMAGE_NAME: hypnoglow/helm-s3 | ||
HELM_VERSION: ${{ matrix.helm }} | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # v3.2.0 | ||
with: | ||
cache: true | ||
go-version-file: 'go.mod' | ||
|
||
- name: Download dependencies | ||
run: | | ||
go mod download -x | ||
- name: Prepare variables | ||
id: vars | ||
uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # v6.1.0 | ||
with: | ||
script: | | ||
const { GITHUB_REF_NAME, GITHUB_REF_TYPE, GITHUB_SHA } = process.env | ||
let helm_version_minor = "${{ matrix.helm }}".split('.').slice(0, -1).join('.') | ||
let plugin_version = `commit.${context.sha}` | ||
if (GITHUB_REF_TYPE === "branch" && GITHUB_REF_NAME === "master") { | ||
plugin_version = "master" | ||
} | ||
if (GITHUB_REF_TYPE === "tag") { | ||
plugin_version = GITHUB_REF_NAME.replace(/^v/, "") | ||
} | ||
let build_date = new Date().toISOString() | ||
core.setOutput('helm_version_minor', helm_version_minor) | ||
core.setOutput('plugin_version', plugin_version) | ||
core.setOutput('build_date', build_date) | ||
core.setOutput('vcs_ref', context.sha) | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1 | ||
with: | ||
images: | | ||
hypnoglow/helm-s3 | ||
tags: | | ||
type=semver,pattern={{ version }},suffix=-helm${{ matrix.helm }} | ||
type=semver,pattern={{ version }},suffix=-helm${{ steps.vars.outputs.helm_version_minor }} | ||
type=ref,event=branch,enable={{ is_default_branch }},suffix=-helm${{ matrix.helm }} | ||
type=ref,event=branch,enable={{ is_default_branch }},suffix=-helm${{ steps.vars.outputs.helm_version_minor }} | ||
type=raw,value=commit.{{ sha }},suffix=-helm${{ matrix.helm }} | ||
type=raw,value=commit.{{ sha }},suffix=-helm${{ steps.vars.outputs.helm_version_minor }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0 | ||
with: | ||
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
HELM_VERSION=${{ matrix.helm }} | ||
PLUGIN_VERSION=${{ steps.vars.outputs.plugin_version }} | ||
BUILD_DATE=${{ steps.vars.outputs.build_date }} | ||
VCS_REF=${{ steps.vars.outputs.vcs_ref }} | ||
push: true # TODO: only push on master and tags. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters