Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cd charts
helm package pybsposter
- id: tagandpush
name: Tag and Push
name: Tag and Push (Harbor)
run: |
export BUILDIMGTAG="`cat Dockerfile | tail -n1 | sed 's/^.*\///g'`"
export FINALBUILDTAG="`cat Dockerfile | tail -n1 | sed 's/^#//g'`"
Expand All @@ -45,6 +45,27 @@ jobs:
CR_PAT: ${{ secrets.CR_PAT }}
CR_USER: ${{ secrets.CR_USER }}
if: github.ref == 'refs/heads/main'
- id: tagandpushdh
name: Tag and Push (Dockerhub)
run: |
export BUILDIMGTAG="`cat Dockerfile | tail -n1 | sed 's/^.*\///g'`"
# Note the replacement to Dockerhub
export FINALBUILDTAG="`cat Dockerfile | tail -n1 | sed 's/^#.*\//idjohnson\//g'`"
export FINALBUILDLATEST="`cat Dockerfile | tail -n1 | sed 's/^#//g' | sed 's/:.*/:latest/'`"
docker tag $BUILDIMGTAG $FINALBUILDTAG
docker tag $BUILDIMGTAG $FINALBUILDLATEST
docker images
echo $CR_PAT | docker login -u $CR_USER --password-stdin
docker push "$FINALBUILDTAG"
# add a "latest" for others to use
docker push $FINALBUILDLATEST
# Push Charts
export CVER="`cat ./charts/pybsposter/Chart.yaml | grep 'version:' | sed 's/version: //' | tr -d '\n'`"
#helm push ./charts/pybsposter-$CVER.tgz oci://harbor.freshbrewed.science/library/
env: # Or as an environment variable
CR_PAT: ${{ secrets.DH_PAT }}
CR_USER: ${{ secrets.DH_USER }}
if: github.ref == 'refs/heads/main'
- id: tagnpushdry
name: Tag and Push (DRY RUN)
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ENV NAME=World
# Run app.py when the container launches
CMD ["python", "app.py"]

#harbor.freshbrewed.science/library/pybsposter:0.0.4
#harbor.freshbrewed.science/library/pybsposter:0.0.5
31 changes: 18 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ def handle_post():
if total_length > 300:
text = text[:(300 - len(link) - 4)] + "... " # Trim and add ellipsis

client = Client()
try:
client = Client()
except Exception as e:
print(f"Failed to connect to server: {e}")

profile = client.login(username, password)

builder = client_utils.TextBuilder().text(text).link(link,link)
text_string = str(builder) # Convert TextBuilder to a string
post = client.send_post(builder)
# Don't really need to like my own posts
# client.like(post.uri, post.cid)

response = {

"YOU ARE:": profile.display_name,
"TEXT": text_string,
"LINK": link
}

return jsonify(response)

try:
post = client.send_post(builder)
response = {
"YOU ARE:": profile.display_name,
"TEXT": text_string,
"LINK": link
}

return jsonify(response)
except Exception as e:
print(f"Failed to post: {e}")
return {'error': 'Failed to send post'}, 500

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)