-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (67 loc) · 2.18 KB
/
build.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
name: Build and push image
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
permissions:
contents: read
id-token: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.vars.outputs.image-tag }}
application: ${{ steps.vars.outputs.application }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set variables
id: vars
env:
EVENT_NAME: ${{ github.event_name }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
GIT_SHA: ${{ github.sha }}
run: |
date="$(date -u +%Y%m%d)"
short_rev="$(git rev-parse --short "$GIT_SHA")"
if [[ "$EVENT_NAME" != "push" || "$REF_TYPE" != "tag" ]]; then
echo "image-tag=${date}-${short_rev}" >> $GITHUB_OUTPUT
echo "application=bacchus-snu/id-front/dev" >> $GITHUB_OUTPUT
else
echo "image-tag=${REF_NAME}" >> $GITHUB_OUTPUT
echo "application=bacchus-snu/id-front/prod" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure registry credentials
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/bacchus-snu/${{ vars.IMAGE_NAME }}:${{ steps.vars.outputs.image-tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
#deploy:
# needs: build
# if: ${{ github.event_name != 'pull_request' }}
# uses: bacchus-snu/cd-manifests/.github/workflows/deploy-application.yaml@main
# with:
# application: ${{ needs.build.outputs.application }}
# image: '${{ vars.ECR_URL }}/${{ vars.IMAGE_NAME }}'
# tag: ${{ needs.build.outputs.tag }}
# secrets:
# app-id: '${{ secrets.CD_GITHUB_APP_ID }}'
# app-private-key: '${{ secrets.CD_GITHUB_APP_SECRET_KEY }}'