mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
6d860acab4
* pin version tags in database cleanup and issues response wf * update all workflow for actions version pin * edit build strategy and a few version pin typo
81 lines
2.5 KiB
YAML
81 lines
2.5 KiB
YAML
---
|
|
name: Clean After PR
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
|
|
jobs:
|
|
build-docker:
|
|
name: Remove feature branch docker images
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
|
|
|
########## ACR ##########
|
|
- name: Login to Azure - QA Subscription
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a # v1.3.0
|
|
with:
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
|
|
|
- name: Login to Azure ACR
|
|
run: az acr login -n bitwardenqa
|
|
|
|
- name: Login to Azure - PROD Subscription
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a # v1.3.0
|
|
with:
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
- name: Login to Azure ACR
|
|
run: az acr login -n bitwardenprod
|
|
|
|
########## Remove Docker images ##########
|
|
- name: Remove the docker image from ACR
|
|
env:
|
|
REGISTRIES: |
|
|
registries:
|
|
- bitwardenprod
|
|
- bitwardenqa
|
|
SERVICES: |
|
|
services:
|
|
- Admin
|
|
- Api
|
|
- Attachments
|
|
- Events
|
|
- EventsProcessor
|
|
- Icons
|
|
- Identity
|
|
- K8S-Proxy
|
|
- MsSql
|
|
- Nginx
|
|
- Notifications
|
|
- Server
|
|
- Setup
|
|
- Sso
|
|
run: |
|
|
for SERVICE in $(echo "${{ env.SERVICES }}" | yq e ".services[]" - )
|
|
do
|
|
for REGISTRY in $( echo "${{ env.REGISTRIES }}" | yq e ".registries[]" - )
|
|
do
|
|
SERVICE_NAME=$(echo $SERVICE | awk '{print tolower($0)}')
|
|
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
|
|
|
|
echo "[*] Checking if remote exists: $REGISTRY.azurecr.io/$SERVICE_NAME:$IMAGE_TAG"
|
|
TAG_EXISTS=$(
|
|
az acr repository show-tags --name $REGISTRY --repository $SERVICE_NAME \
|
|
| jq --arg $TAG "$IMAGE_TAG" -e '. | any(. == "$TAG")'
|
|
)
|
|
|
|
if [[ "$TAG_EXISTS" == "true" ]]; then
|
|
echo "[*] Tag exists. Removing tag"
|
|
az acr repository delete --name $REGISTRY --image $SERVICE_NAME:$IMAGE_TAG --yes
|
|
else
|
|
echo "[*] Tag does not exist. No action needed"
|
|
fi
|
|
done
|
|
done
|
|
|
|
- name: Log out of Docker
|
|
run: docker logout
|