-
Notifications
You must be signed in to change notification settings - Fork 0
31 lines (26 loc) · 1.21 KB
/
package.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
name: Build and Push Docker Image
on:
release:
types: [published]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check Out Repository
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build Docker image
run: |
REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
TAG=$(echo ${{ github.ref_name }} | tr '/' '-') # Replace / with -
docker build . -t ghcr.io/$REPO_LOWER:$TAG -t ghcr.io/$REPO_LOWER:latest --no-cache --target prod
- name: Push Docker image to GitHub Registry
run: |
REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
TAG=$(echo ${{ github.ref_name }} | tr '/' '-') # Replace / with -
docker push ghcr.io/$REPO_LOWER:$TAG
docker push ghcr.io/$REPO_LOWER:latest