diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index ed3de1d..71f0fbf 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -3,60 +3,14 @@ name: docker-image-push-join on: push: branches: [ main ] - -env: - DOCKER_USER: ${{secrets.DOCKER_USER}} - DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} + + workflow_dispatch: jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v2 - - - name: Set docker image tags - id: set-tags - run: | - set -a; source .env; set +a - echo "JOIN_IMAGE_TAG=${JOIN_IMAGE_TAG}" >> "$GITHUB_OUTPUT" - echo "Current join-page image tag (push): ${JOIN_IMAGE_TAG}" - - - name: docker login - run: | # log into docker hub account - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - - name: Get current date # get the date of the build - id: date - run: echo "date=$(date +'%Y-%m-%d--%M-%S')" >> "$GITHUB_OUTPUT" - - - name: Run a one-line script - run: echo running in repo ${GITHUB_REPOSITORY#*/} branch ${GITHUB_REF##*/} on ${{ steps.date.outputs.date }} - - - name: build docker image - run: | - docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} ./frontend - docker images - - - name: push docker image - run: | - docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} - - - name: Update .env file - run: | - echo "JOIN_IMAGE_TAG=${GITHUB_REF##*/}_${{ steps.date.outputs.date }}" > .env - - - name: Add, Commit, Push changes to .env file - run: | - git config --local user.email "action@github.com" - git config --local user.name "Github Actions bot to update .env with latest tags" - if git diff --quiet; then - echo "Latest timestamp already present in .env file, no changes to commit" - else - git add .env - git commit -m "Updated docker image tags in .env file to the latest timestamp" - git push origin - fi + build: + if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') }} + uses: e-mission/e-mission-server/.github/workflows/reusable_image_build_push.yml@master + with: + repo: ${{ github.event.repository.name }} + branch: ${{ github.ref_name }} + secrets: inherit