Update patch.yml #2
Workflow file for this run
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 Develop Release | |
on: | |
push: | |
branches: [ patch-* ] | |
pull_request: | |
branches: [ patch-* ] | |
delete: | |
branches: | |
- patch-* | |
jobs: | |
docker-latest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: checkout the repo | |
run: | | |
docker login --username ${{ secrets.GH_USERNAME }} --password ${{ secrets.GH_TOKEN }} ghcr.io | |
docker build --build-arg BRANCH=$(git rev-parse --abbrev-ref HEAD) -t ghcr.io/drazzilb08/userscripts:dev . | |
docker push ghcr.io/drazzilb08/userscripts:${{ github.ref_slug }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
build-args: | | |
"BRANCH=$(git rev-parse --abbrev-ref HEAD)" | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/userscripts:${{ github.ref_slug }} | |
- name: Delete image from GitHub Container Registry if branch was deleted | |
if: github.event_name == 'delete' | |
run: | | |
docker logout ghcr.io | |
docker login --username ${{ secrets.GH_USERNAME }} --password ${{ secrets.GH_TOKEN }} ghcr.io | |
docker image rm ghcr.io/drazzilb08/userscripts:${{ github.ref_slug }} | |
- name: Delete image from Docker Hub if branch was deleted | |
if: github.event_name == 'delete' | |
run: | | |
docker logout | |
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }} | |
docker image rm ${{ secrets.DOCKER_USERNAME }}/userscripts:${{ github.ref_slug }} | |