check := clippy #12
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: Test On Docker | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
env: | |
DOCKER_REGISTRY: docker.io | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check if image needs to update | |
id: check-image | |
run: | | |
IMAGE_NAME=learning-rvemu-for-book-env | |
IMAGE_TAG=latest | |
IMAGE_ID=$(docker inspect --format='{{.Id}}' $DOCKER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG || true) | |
if [ -z "$IMAGE_ID" ]; then | |
echo "Image not found in registry" | |
docker pull $DOCKER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG | |
fi | |
LOCAL_IMAGE_ID=$(docker inspect --format='{{.Id}}' $IMAGE_NAME:$IMAGE_TAG || true) | |
if [ "$IMAGE_ID" != "$LOCAL_IMAGE_ID" ]; then | |
echo "Image needs to be updated" | |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin $DOCKER_REGISTRY | |
docker tag $IMAGE_NAME:$IMAGE_TAG $DOCKER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG | |
docker push $DOCKER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG | |
else | |
echo "Image is up to date" | |
fi | |
- name: Run image | |
if: steps.check-image.outcome == 'success' | |
run: | | |
IMAGE_NAME=learning-rvemu-for-book-env | |
IMAGE_TAG=latest | |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin $DOCKER_REGISTRY | |
docker run $DOCKER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG |