-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (92 loc) · 3.62 KB
/
manual-deploy-unstable.yaml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Manual Deploy Unstable
on:
workflow_dispatch:
inputs:
tag:
description: tag
required: true
env:
IMAGE_NAME: ldap-to-alma-patrons
TANKA_ENV: patron-load/testing
jobs:
build-deploy-unstable:
name: Deploy ${{ github.event.inputs.tag }} to ${{ env.TANKA_ENV }}
runs-on: ubuntu-latest
steps:
- name: Clone latest repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check that the tag exists in repo
id: tag_check
run: |
if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then
echo 'tag=${{ github.event.inputs.tag }}' >> $GITHUB_OUTPUT
elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then
echo "tag=`git rev-parse '${{ github.event.inputs.tag }}'`" >> $GITHUB_OUTPUT
else
echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}"
echo "Aborting deployment."
false
fi
- name: Log into Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check that the tag exists in container registry
id: image_check
run: |
if docker manifest inspect ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then
echo 'image_exists=true' >> $GITHUB_OUTPUT
echo "image exists!"
else
echo "image doesn't exist; Starting to Build and push image"
fi
- name: Checkout Correct repository
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}
- name: Build and Push
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.prod
secrets: |
"gh_package_read_token=${{ secrets.GH_PACKAGE_READ_TOKEN }}"
push: true
tags: ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}}
#- name: Generate app token
#id: generate_token
#uses: tibdex/github-app-token@v1
#with:
#app_id: ${{ secrets.SEARCH_CONFIG_REPO_RW_APP_ID }}
#installation_id: ${{ secrets.SEARCH_CONFIG_REPO_RW_INSTALL_ID }}
#private_key: ${{ secrets.SEARCH_CONFIG_REPO_RW_KEY }}
#- name: Set message
#id: set_message
#run: |
#echo "TITLE=Update ${{ env.TANKA_ENV }} to ${{ steps.tag_check.outputs.tag }}" >> $GITHUB_OUTPUT
#echo "DESCRIPTION=Originating repository is ${{ github.repository }}\nRun ID is $GITHUB_RUN_ID\nUser is ${{ github.actor }}" >> $GITHUB_OUTPUT
#- name: Set PAYLOAD
#run: |
#data=$(echo '[
#{
#"environment": "${{ env.TANKA_ENV }}",
#"key": "web",
#"image": "ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }}"
#}
#]' | python -c 'import json, sys;var=json.dumps(json.load(sys.stdin));print(json.dumps(var))' )
#echo "PAYLOAD={\"title\": \"${{ steps.set_message.outputs.TITLE }}\",\"description\": \"${{ steps.set_message.outputs.DESCRIPTION }}\", \"data\": $data }" >> $GITHUB_ENV
#- name: echo payload
#run: echo $PAYLOAD
#- name: Send the message
#uses: peter-evans/repository-dispatch@v2
#with:
#event-type: update-image
#token: ${{ steps.generate_token.outputs.token }}
#repository: mlibrary/search-kube
#client-payload: ${{ env.PAYLOAD }}