|
4 | 4 | push:
|
5 | 5 | branches: [ main ]
|
6 | 6 |
|
7 |
| -env: |
8 |
| - DOCKER_USER: ${{secrets.DOCKER_USER}} |
9 |
| - DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} |
10 |
| - |
11 | 7 | jobs:
|
12 |
| - |
13 |
| - build: |
14 |
| - |
15 |
| - runs-on: ubuntu-latest |
16 |
| - |
17 |
| - steps: |
18 |
| - |
19 |
| - - uses: actions/checkout@v2 |
20 |
| - |
21 |
| - - name: Set docker image tags |
22 |
| - id: set-tags |
23 |
| - run: | |
24 |
| - set -a; source .env; set +a |
25 |
| - echo "JOIN_IMAGE_TAG=${JOIN_IMAGE_TAG}" >> "$GITHUB_OUTPUT" |
26 |
| - echo "Current join-page image tag (push): ${JOIN_IMAGE_TAG}" |
27 |
| -
|
28 |
| - - name: docker login |
29 |
| - run: | # log into docker hub account |
30 |
| - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD |
31 |
| -
|
32 |
| - - name: Get current date # get the date of the build |
33 |
| - id: date |
34 |
| - run: echo "date=$(date +'%Y-%m-%d--%M-%S')" >> "$GITHUB_OUTPUT" |
35 |
| - |
36 |
| - - name: Run a one-line script |
37 |
| - run: echo running in repo ${GITHUB_REPOSITORY#*/} branch ${GITHUB_REF##*/} on ${{ steps.date.outputs.date }} |
38 |
| - |
39 |
| - - name: build docker image |
40 |
| - run: | |
41 |
| - docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} ./frontend |
42 |
| - docker images |
43 |
| -
|
44 |
| - - name: push docker image |
45 |
| - run: | |
46 |
| - docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} |
47 |
| -
|
48 |
| - - name: Update .env file |
49 |
| - run: | |
50 |
| - echo "JOIN_IMAGE_TAG=${GITHUB_REF##*/}_${{ steps.date.outputs.date }}" > .env |
51 |
| -
|
52 |
| - - name: Add, Commit, Push changes to .env file |
53 |
| - run: | |
54 |
| - git config --local user.email "[email protected]" |
55 |
| - git config --local user.name "Github Actions bot to update .env with latest tags" |
56 |
| - if git diff --quiet; then |
57 |
| - echo "Latest timestamp already present in .env file, no changes to commit" |
58 |
| - else |
59 |
| - git add .env |
60 |
| - git commit -m "Updated docker image tags in .env file to the latest timestamp" |
61 |
| - git push origin |
62 |
| - fi |
| 8 | + build: |
| 9 | + if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') }} |
| 10 | + uses: e-mission/e-mission-server/.github/workflows/reusable_image_build_push.yml@master |
| 11 | + with: |
| 12 | + repo: ${{ github.event.repository.name }} |
| 13 | + branch: ${{ github.ref_name }} |
| 14 | + secrets: inherit |
0 commit comments