-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
140 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,72 @@ | ||
name: Docker Images CI | ||
|
||
on: [pull_request] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
pull_request: | ||
|
||
env: | ||
PLATFORM: linux/amd64 | ||
# TODO: Replace with renovate/renovate | ||
DOCKER_REPO: renovate/cache-test | ||
|
||
jobs: | ||
build: | ||
name: Build image | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 20 | ||
|
||
strategy: | ||
matrix: | ||
file: [Dockerfile, Dockerfile.slim] | ||
tag: [latest, slim] | ||
|
||
env: | ||
DOCKER_FILE: Dockerfile.${{ matrix.tag }} | ||
DOCKER_TAG: ${{ matrix.tag }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- name: Overwrite env for latest tag | ||
if: matrix.tag == 'latest' | ||
run: | | ||
echo "::set-env name=DOCKER_FILE::Dockerfile" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
version: v0.3.1 | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Build the Docker image | ||
run: | | ||
docker buildx build \ | ||
--platform ${PLATFORM} \ | ||
--output "type=docker" \ | ||
--tag renovate \ | ||
--file ./${{ matrix.file }} . | ||
--output=type=docker \ | ||
--cache-from=${DOCKER_REPO}:cache-${DOCKER_TAG} \ | ||
--tag=renovate \ | ||
--file=./${DOCKER_FILE} . | ||
- name: Test the Docker image | ||
run: | | ||
docker run --rm -t renovate --version | ||
- name: Image history | ||
run: docker history renovate | ||
|
||
- name: Image size | ||
run: docker image ls | grep renovate | ||
|
||
- name: Push the Docker image | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
run: | | ||
echo "${{ secrets.DOCKER_RENOVATERELEASE_TOKEN }}" | docker login -u renovaterelease --password-stdin | ||
docker buildx build \ | ||
--platform ${PLATFORM} \ | ||
--output=type=registry \ | ||
--cache-from=${DOCKER_REPO}:cache-${DOCKER_TAG} \ | ||
--cache-to=${DOCKER_REPO}:cache-${DOCKER_TAG} \ | ||
--tag=${DOCKER_REPO}:test-${DOCKER_TAG} \ | ||
--file=./${DOCKER_FILE} . |
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,99 @@ | ||
name: Release CI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
env: | ||
PLATFORM: linux/amd64 | ||
# TODO: Replace with renovate/renovate | ||
DOCKER_REPO: renovate/cache-test | ||
|
||
jobs: | ||
docker-release: | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 30 | ||
|
||
strategy: | ||
matrix: | ||
tag: [latest, slim] | ||
|
||
env: | ||
DOCKER_FILE: Dockerfile.${{ matrix.tag }} | ||
DOCKER_TAG: ${{ matrix.tag }} | ||
|
||
steps: | ||
- name: Overwrite env for latest tag | ||
if: matrix.tag == 'latest' | ||
run: | | ||
echo "::set-env name=DOCKER_FILE::Dockerfile" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
version: v0.3.1 | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Build the Docker image | ||
run: | | ||
docker buildx build \ | ||
--platform ${PLATFORM} \ | ||
--output=type=docker \ | ||
--cache-from=${DOCKER_REPO}:cache-${DOCKER_TAG} \ | ||
--tag=renovate \ | ||
--file=./${DOCKER_FILE} . | ||
- name: Test the Docker image | ||
run: | | ||
docker run --rm -t renovate --version | ||
- name: Image history | ||
run: docker history renovate | ||
- name: Image size | ||
run: docker image ls | grep renovate | ||
|
||
- name: Generate tags | ||
run: | | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Tag base | ||
tags="${DOCKER_REPO}:${DOCKER_TAG}" | ||
echo "Tagging ${DOCKER_REPO}:${DOCKER_TAG}" | ||
SEMVER_REGEX="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)?$" | ||
if ! [[ "$VERSION" =~ $SEMVER_REGEX ]]; then | ||
echo Not a semver tag - skipping | ||
exit 1 | ||
fi | ||
major=${BASH_REMATCH[1]} | ||
minor=${BASH_REMATCH[2]} | ||
patch=${BASH_REMATCH[3]} | ||
slim=${DOCKER_TAG#latest} | ||
slim=${slim:+-}${slim} | ||
# Tag for versions additional | ||
for tag in {"${major}${slim}","${major}.${minor}${slim}","${major}.${minor}.${patch}${slim}"}; do | ||
echo "Tagging ${DOCKER_REPO}:${tag}" | ||
tags+=",${DOCKER_REPO}:${tag}" | ||
done | ||
echo "::set-env name=TAGS::${tags}" | ||
- name: Push the Docker image | ||
run: | | ||
echo "${{ secrets.DOCKER_RENOVATERELEASE_TOKEN }}" | docker login -u renovaterelease --password-stdin | ||
docker buildx build \ | ||
--platform ${PLATFORM} \ | ||
--output=type=registry \ | ||
--cache-from=${DOCKER_REPO}:cache-${DOCKER_TAG} \ | ||
--tag=${TAGS} \ | ||
--file=./${DOCKER_FILE} . |