fix(cicd): try to fix workflow #17
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: Docker Build and Push | |
on: | |
workflow_run: | |
workflows: ["Server build"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/docker.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and tag Docker image | |
run: | | |
git fetch --tags | |
version=$(echo $(git tag --sort=-creatordate | head -n 1)) | |
echo $version | |
docker buildx build -t ${{ secrets.DOCKER_USERNAME }}/photron:$version . --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --load | |
docker tag ${{ secrets.DOCKER_USERNAME }}/photron:$version ${{ secrets.DOCKER_USERNAME }}/photron:latest | |
- name: Push image to Docker Hub | |
run: | | |
version=$(echo $(git tag --sort=-creatordate | head -n 1)) | |
docker push ${{ secrets.DOCKER_USERNAME }}/photron:$version | |
docker push ${{ secrets.DOCKER_USERNAME }}/photron:latest |