diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index e2717f8..8a45178 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -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'`" @@ -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: | diff --git a/Dockerfile b/Dockerfile index 03343c9..4bb7cca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file +#harbor.freshbrewed.science/library/pybsposter:0.0.5 \ No newline at end of file diff --git a/app.py b/app.py index 50e8bf0..fbe4d18 100644 --- a/app.py +++ b/app.py @@ -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)