Skip to content
The Chat Archive
wizardlm-13b Arena Human Preference 55K

how to write a github workfolw that can check if a docker image is updated since last…

  1. User

    how to write a github workfolw that can check if a docker image is updated since last known version

  2. Assistant

    To create a GitHub Workflow that checks if a Docker image has been updated since the last known version, you can follow these steps:

    1. Create a docker-check directory in your repository.
    2. Inside the docker-check directory, create a file named workflow.yml to define the GitHub Workflow.
    3. Add the following content to workflow.yml:
    name: Docker Image Update Check
    
    on:
      push:
        branches:
          - main
    
    jobs:
      check-docker-image:
        runs-on: ubuntu-latest
    
        steps:
        - name: Checkout repository
          uses: actions/checkout@v2
    
        - name: Log in to Docker Hub
          uses: docker/login-action@v1
          with:
            username: ${{ docker.username }}
            password: ${{ docker.password }}
            email: ${{ docker.email }}
    
        - name: Pull latest image
          run: |
            docker pull $IMAGE_NAME:latest
    
        - name: Check image digest
          run: |
            docker image inspect --format='{{.ID}}:{{.Tag}}:{{.Digest}}' $IMAGE_NAME
          output:
            success_status: 0
            json_events: true
    
        - name: Get known image digest
          id: get_known_digest
          run: |
            known_digest=$(cat known-digest.txt)
          env:
            - name: known_digest
              secret:
                name: known-digest
    
        - name: Check if image has been updated
          run: |
            if [[ "${AIR_GITHUB_COMMIT_SHA}" == "${known_digest}" ]]; then
              echo "Image has not been updated since last known version."
              exit 0
            fi
          condition: ${{ github.event_name }} != "push"
          fail_fast: true
          message: "Image has been updated since last known version."
    
    1. Replace IMAGE_NAME with the name of your Docker image and IMAGE_TAG with the tag of your image (usually latest).
    2. Create

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.