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