Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
zoumingzhe committed Jun 7, 2024
1 parent 9fa244e commit 3fc73f2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the "master" branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# - name: "Login to GitHub Container Registry"
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{github.actor}}
# password: ${{secrets.GITHUB_TOKEN}}

# - name: Pull image
# run: |
# make pull
# make push

- name: Check image
run: make check
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
MAKEFLAGS += --always-make

all: pull push

check:
python scripts/digest.py

pull:
docker pull docker.io/mingzhebaosheng/directory-lister:4.0.0
docker image ls

push:
docker tag docker.io/mingzhebaosheng/directory-lister:4.0.0 ghcr.io/podboy/directory-lister:4.0.0
docker image ls
docker push ghcr.io/podboy/directory-lister:4.0.0
26 changes: 26 additions & 0 deletions scripts/digest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import requests
import json

# 设置你的Docker镜像名和tag
image_name = "library/ubuntu"
tag_name = "latest"

# 设置Docker Registry的地址
registry_url = "https://registry-1.docker.io"

# 构造请求manifest的URL
manifest_url = f"{registry_url}/v2/{image_name}/manifests/{tag_name}"

# 发送请求获取manifest
response = requests.get(manifest_url)

# 检查请求是否成功
if response.status_code == 200:
# 解析JSON数据
manifest = json.loads(response.content)

# 打印hash值
config_digest = manifest["config"]["digest"]
print(f"The hash for the tag is: {config_digest}")
else:
print("Failed to fetch manifest")

0 comments on commit 3fc73f2

Please sign in to comment.