Skip to content

Commit

Permalink
Add dockerhub-readme action (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreDelpy authored Sep 3, 2024
1 parent 3446484 commit 578c84e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/dockerhub_readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update DockerHub Description

on:
push:
branches:
- main
- develop
tags:
- '*.*.*'
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: |
# Read the content of the README.md file and escape newlines and quotes
DESCRIPTION=$(jq -Rs '.' 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)
# 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"

0 comments on commit 578c84e

Please sign in to comment.