Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
build(docker): cleanup after branch removal (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
l3uddz authored Aug 9, 2020
1 parent 22df8c5 commit eb45791
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- '*'
tags:
- 'v*'
pull_request:
types: [opened, reopened, edited, ready_for_review]

jobs:
build:
Expand Down
43 changes: 6 additions & 37 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
name: Docker Cleanup

on:
pull_request:
types: [closed, removed]
delete:
on: delete

jobs:
cleanup_branch:
if: startsWith(github.event.ref_type, 'branch') == true
runs-on: ubuntu-latest
steps:
- name: Determine docker tag
env:
GH_EVENT_REF: ${{ github.event.ref }}
id: dockertag
shell: bash
run: echo "::set-output name=tag::${GH_EVENT_REF#refs/heads/}"

- name: Remove branch docker tag
shell: bash
env:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag: ${{ steps.dockertag.outputs.tag }}
run: |
docker run --rm lumir/remove-dockerhub-tag --user "$username" --password "$password" cloudb0x/autoscan:$tag
cleanup_pr:
if: startsWith(github.event.ref, 'refs/pull/') == true
env:
GH_EVENT_REF: ${{ github.event.ref }}
runs-on: ubuntu-latest
steps:
- name: Determine pull request tag
id: githubpr
shell: bash
run: echo "::set-output name=tag::${GH_EVENT_REF#refs/pull/}"

- name: Determine docker tag
- name: Sanitize branch docker tag
uses: frabert/replace-string-action@master
id: dockertag
with:
pattern: '[:\.]+'
string: "${{ steps.githubpr.outputs.tag }}"
pattern: '[:\.\/]+'
string: "${{ github.event.ref }}"
replace-with: '-'
flags: 'g'

- name: Remove pull request docker tag
- name: Remove branch docker tag
shell: bash
env:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag: ${{ steps.dockertag.outputs.replaced }}
run: |
docker run --rm lumir/remove-dockerhub-tag --user "$username" --password "$password" cloudb0x/autoscan:pr-$tag
docker run --rm lumir/remove-dockerhub-tag --user "$username" --password "$password" cloudb0x/autoscan:$tag

0 comments on commit eb45791

Please sign in to comment.