Add dockerhub-readme action #4
Workflow file for this run
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 DockerHub Description | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
update-dockerhub: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Update DockerHub Description | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
DOCKERHUB_REPO: "samply/obds2fhir" | |
# run: | | |
# DESCRIPTION=$(cat README.md) | |
# curl -s -X PATCH \ | |
# -H "Authorization: JWT $(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "${DOCKERHUB_USERNAME}", "password": "${DOCKERHUB_TOKEN}"}' https://hub.docker.com/v2/users/login/ | jq -r .token)" \ | |
# -H "Content-Type: application/json" \ | |
# -d '{"full_description": "'"$DESCRIPTION"'"}' \ | |
# https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/ | |
run: | | |
# Read the content of the README.md file | |
DESCRIPTION=$(cat README.md) | |
# Log in to DockerHub and get the JWT token | |
TOKEN_RESPONSE=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'"${DOCKERHUB_USERNAME}"'", "password": "'"${DOCKERHUB_TOKEN}"'"}' https://hub.docker.com/v2/users/login/) | |
TOKEN=$(echo $TOKEN_RESPONSE | jq -r .token) | |
# Check if TOKEN is not empty | |
if [ -z "$TOKEN" ]; then | |
echo "Failed to authenticate with DockerHub. Response: $TOKEN_RESPONSE" | |
exit 1 | |
fi | |
# Update the DockerHub repository description | |
UPDATE_RESPONSE=$(curl -s -X PATCH \ | |
-H "Authorization: JWT $TOKEN" \ | |
-H "Content-Type: application/json" \ | |
-d '{"full_description": "'"$DESCRIPTION"'"}' \ | |
https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/) | |
echo "Update response: $UPDATE_RESPONSE" |