Switch to docker hub because github packages is useless.

This commit is contained in:
projectmoon 2020-08-31 21:35:19 +00:00
parent b90f1fe92a
commit 374f426961
1 changed files with 27 additions and 31 deletions

View File

@ -2,7 +2,6 @@ name: Dicebot CI
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
@ -18,8 +17,6 @@ env:
CARGO_TERM_COLOR: always
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
build_and_test:
runs-on: ubuntu-latest
steps:
@ -29,42 +26,41 @@ jobs:
- name: Run tests
run: cargo test --verbose
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
docker_push:
# Ensure test job passes before pushing image.
docker_push_latest:
needs: build_and_test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Build and push Docker images
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: myorg/myrepository
tags: latest
push: ${{ startsWith(github.ref, 'master') }}
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
docker_push_tag:
needs: build_and_test
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
runs-on: ubuntu-latest
if: github.event_name == 'push'
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
steps:
- name: Checkout code
uses: actions/checkout@v2
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Build and push Docker images
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: myorg/myrepository
tags: latest
tag_with_ref: true
push: ${{ startsWith(github.ref, 'refs/tags/') }}