forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (42 loc) · 1.34 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Push docker images
on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+
permissions:
contents: read
jobs:
push-core-image:
name: Push dependabot-core image to docker hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare environment variables
run: |
echo "BASE_IMAGE=ubuntu:18.04" >> $GITHUB_ENV
echo "CORE_IMAGE=dependabot/dependabot-core" >> $GITHUB_ENV
- name: Build dependabot-core image
env:
DOCKER_BUILDKIT: 1
run: |
docker build \
-t "$CORE_IMAGE:latest" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from "$BASE_IMAGE" \
--cache-from "$CORE_IMAGE:latest" \
.
- name: Log in to the Docker registry
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Push latest image
run: |
docker push "$CORE_IMAGE:latest"
- name: Push tagged image
if: "contains(github.ref, 'refs/tags')"
run: |
VERSION="$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" common/lib/dependabot/version.rb)"
docker tag "$CORE_IMAGE:latest" "$CORE_IMAGE:$VERSION"
docker push "$CORE_IMAGE:$VERSION"