Echo docker version and run container as root #1
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
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" |