Merge pull request #39 from FortesenseLabs/develop #30
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: Push MetaTrader5 Release to Docker Hub | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- created | |
# Run only for tags that start with "v" (e.g. "v1.0.0") | |
tags: | |
- 'v*' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check if MT5 folder has changed | |
id: folder-changed | |
run: | | |
if git diff --quiet HEAD^ HEAD -- MT5/; then | |
echo "MT5 folder has not changed" | |
echo "FOLDER_CHANGED=false" >> $GITHUB_OUTPUT | |
else | |
echo "MT5 folder has changed" | |
echo "FOLDER_CHANGED=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Build and push Docker image | |
if: ${{ steps.folder-changed.outputs.FOLDER_CHANGED }} == 'true' | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_REPO: metatrader | |
DOCKER_TAG: 5 | |
run: | | |
docker build -t $DOCKER_REPO:$DOCKER_TAG -f MT5/Dockerfile.MetaTrader5 ./MT5 | |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | |
docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_USERNAME/$DOCKER_REPO:$DOCKER_TAG | |
docker push $DOCKER_USERNAME/$DOCKER_REPO:$DOCKER_TAG |