forked from geonetwork/geonetwork-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (38 loc) · 1.74 KB
/
cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Cleanup
run-name: 🧹 Cleanup operations for 🌱 ${{github.event.ref}}
env:
# a list of apps to build and publish on releases
APP_NAMES: datafeeder,datahub
on:
delete:
branches:
- '*'
jobs:
docker-cleanup:
name: Delete docker images on Dockerhub
runs-on: ubuntu-latest
steps:
- name: generate Dockerhub auth
id: docker-auth
run: |
BASE_64_TOKEN=$(echo '{"username":"${{ secrets.DOCKER_HUB_USERNAME }}","password":"${{ secrets.DOCKER_HUB_PASSWORD }}","auth":"","email":"[email protected]"}' | base64)
echo ::add-mask::${BASE_64_TOKEN}
echo ::set-output name=DOCKER_AUTH::${BASE_64_TOKEN}
- name: delete docker images for the given applications and branch
# first list apps separated by line breaks
# then for each do a curl call on Dockerhub API to delete the image
run: |
echo "${{ env.APP_NAMES }}" | awk -vRS=',' '{print $1}' | \
xargs -I{} curl -X DELETE "https://hub.docker.com/v2/repositories/geonetwork/geonetwork-ui-{}/${{ github.event.ref }}/" -H "X-Registry-Auth: ${{steps.docker-auth.outputs.DOCKER_AUTH}}"
storybook-cleanup:
name: Delete storybook files on Github Pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Remove directory ${{github.event.ref}}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
touch .empty
npx gh-pages --dist . --src .empty --remove "${{github.event.ref}}" --no-history --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"