-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (37 loc) · 1.13 KB
/
push-to-ghcr.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
name: Push to Github Container Registry
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: The value of the release version tag, e.g. v0.12.0
env:
IMAGE_NAME: serverless-tools-gha
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build image
run: |
docker build . \
--file Dockerfile \
--tag "$IMAGE_NAME" \
--label org.opencontainers.image.source=https://github.com/${{ github.repository }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
IMAGE_ID=ghcr.io/fac/"$IMAGE_NAME"
VERSION="v${{ github.event.inputs.version }}"
echo IMAGE_ID="$IMAGE_ID"
echo VERSION="$VERSION"
docker tag "$IMAGE_NAME" "$IMAGE_ID":"$VERSION"
docker push "$IMAGE_ID":"$VERSION"