mongo-backup-service: build & push container #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "mongo-backup-service: build & push container" | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: ~ | |
permissions: | |
contents: read | |
jobs: | |
build-push-container-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Code check-out | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set commit hash | |
run: | | |
echo COMMIT_HASH_SHORT=$(echo "${GITHUB_SHA}" | cut -c -7) >> "${GITHUB_ENV}" | |
- name: Set image name | |
run: | | |
echo IMAGE_NAME=$(echo "slavafomin/mongo-backup") >> "${GITHUB_ENV}" | |
- name: Set image tags | |
run: | | |
echo IMAGE_HASHED_TAG=$(echo "${IMAGE_NAME}:${COMMIT_HASH_SHORT}") >> "${GITHUB_ENV}" | |
echo IMAGE_LATEST_TAG=$(echo "${IMAGE_NAME}:latest") >> "${GITHUB_ENV}" | |
- name: Build and push the image | |
run: | | |
docker build --file "packages/mongo-backup-service/docker/Dockerfile" --tag "${IMAGE_HASHED_TAG}" --tag "${IMAGE_LATEST_TAG}" packages/mongo-backup-service | |
docker push --all-tags "${IMAGE_NAME}" |