fomatting #3
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: Update Docker Hub README | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Update Docker Hub README | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
run: | | |
export DOCKERHUB_REPO="yourusername/yourrepo" | |
export README_FILE="README.md" | |
# Fetch the README content | |
README_CONTENT=$(cat $README_FILE) | |
# Create JSON payload | |
JSON_PAYLOAD=$(jq -n --arg msg "$README_CONTENT" '{"registry":"registry-1.docker.io","full_description":$msg}') | |
# Update README on Docker Hub | |
curl -s -X PATCH \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: JWT $DOCKERHUB_TOKEN" \ | |
-d "$JSON_PAYLOAD" \ | |
"https://hub.docker.com/v2/repositories/$DOCKERHUB_REPO/" |