diff --git a/.github/workflows/graphql.yaml b/.github/workflows/graphql.yaml index bf781b6..62c3903 100644 --- a/.github/workflows/graphql.yaml +++ b/.github/workflows/graphql.yaml @@ -67,18 +67,28 @@ jobs: tags="$BRANCH" fi + echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV + # should we push to dockerhub, and is there a README DOCKERHUB_PUSH="false" DOCKERHUB_README="false" if [ "${{ github.repository }}" == "${{ env.MAIN_REPO }}" ]; then - if [ "${{ secrets.DOCKERHUB_USERNAME }}" != "" -a "${{ secrets.DOCKERHUB_PASSWORD }}" != "" ]; then - DOCKERHUB_PUSH="true" - if [ -e "README.md" ]; then - DOCKERHUB_README="true" + if [ ${BRANCH} == "main" ]; then + if [ "${{ secrets.DOCKERHUB_USERNAME }}" != "" -a "${{ secrets.DOCKERHUB_PASSWORD }}" != "" ]; then + DOCKERHUB_PUSH="true" + if [ -e "README.md" ]; then + DOCKERHUB_README="true" + fi fi fi fi + # should we push to Github + GITHUB_PUSH="false" + if [ "${{ github.repository }}" == "${{ env.MAIN_REPO }}" ]; then + GITHUB_PUSH="true" + fi + # should we push to NCSA NCSAHUB_PUSH="false" if [ "${{ github.repository }}" == "${{ env.MAIN_REPO }}" ]; then @@ -97,7 +107,9 @@ jobs: if [ "$NCSAHUB_PUSH" == "true" ]; then IMAGES="${IMAGES}${NCSAHUB}/${IMAGE}:${tag}," fi - # IMAGES="${IMAGES}ghcr.io/${OWNER_LC}/${IMAGE}:${tag}," + if [ "$GITHUB_PUSH" == "true" ]; then + IMAGES="${IMAGES}ghcr.io/${OWNER_LC}/${IMAGE}:${tag}," + fi done IMAGES="${IMAGES%,*}" @@ -107,12 +119,14 @@ jobs: echo "DOCKERHUB_README=${DOCKERHUB_README}" echo "DOCKERHUB_PUSH=${DOCKERHUB_PUSH}" echo "NCSAHUB_PUSH=${NCSAHUB_PUSH}" + echo "GITHUB_PUSH=${GITHUB_PUSH}" echo "IMAGES=${IMAGES}" echo "BRANCH=${BRANCH}" >> $GITHUB_ENV echo "VERSION=${VERSION}" >> $GITHUB_ENV echo "DOCKERHUB_README=${DOCKERHUB_README}" >> $GITHUB_ENV echo "DOCKERHUB_PUSH=${DOCKERHUB_PUSH}" >> $GITHUB_ENV + echo "GITHUB_PUSH=${GITHUB_PUSH}" >> $GITHUB_ENV echo "NCSAHUB_PUSH=${NCSAHUB_PUSH}" >> $GITHUB_ENV echo "IMAGES=${IMAGES}" >> $GITHUB_ENV @@ -157,6 +171,7 @@ jobs: # build the docker images - name: Build and push docker + if: env.DOCKERHUB_PUSH == 'true' || env.NCSAHUB_PUSH == 'true' || env.GITHUB_PUSH == 'true' uses: docker/build-push-action@v3 with: context: ./ @@ -179,4 +194,4 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} repository: ${{ env.DOCKERHUB_ORG }}/${{ github.event.repository.name }} - readme-filepath: README.md \ No newline at end of file + readme-filepath: README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index e2bc49a..5edb76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Github action for auto generating docker container [#4](https://github.com/ncsa/standalone-smm-smile-graphql/issues/4) +### Changed +- Github action goes to Docker Hub when it only releases a tag [#8](https://github.com/ncsa/standalone-smm-smile-graphql/issues/8) + ## [0.2.8] - 2023-08-04 ### Added - Support for Twitter V2 API [#2](https://github.com/ncsa/standalone-smm-smile-graphql/issues/2)