change pushing to docker image repo #6
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: build | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build and push master image | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
USERNAME: ${{ github.actor }} | |
run: | | |
docker build -t radiot/tg-retrans:master . | |
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin | |
docker push radiot/tg-retrans:master | |
- name: build and push tagged image | |
if: github.event_name == 'push' && github.event.ref_type == 'tag' | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
USERNAME: ${{ github.actor }} | |
run: | | |
GIT_TAG="${GITHUB_REF#refs/tags/}" | |
docker build -t radiot/tg-retrans:${GIT_TAG} . | |
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin | |
docker push radiot/tg-retrans:${GIT_TAG} | |
docker tag radiot/tg-retrans:${GIT_TAG} radiot/tg-retrans:latest | |
docker push radiot/tg-retrans:latest |