forked from wei/pull
-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (39 loc) · 1.53 KB
/
publish.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
name: Build and Push
on:
push:
branches:
- master
jobs:
build:
name: Build and Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- run: npm ci
- run: npm test
- name: Compute repo name
id: repo
run: echo name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Build Docker Image
run: |
docker pull ghcr.io/${{ steps.repo.outputs.name }}:latest || :
docker build -t ghcr.io/${{ steps.repo.outputs.name }}:latest . \
--cache-from ghcr.io/${{ steps.repo.outputs.name }}:latest \
--build-arg VCS_REF=${{ github.sha }} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Push Docker Image to GitHub Container Registry
run: |
docker push ghcr.io/${{ steps.repo.outputs.name }}:latest
- name: Login to GitHub Package Registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push Docker Image to GitHub Package Registry
run: |
docker tag ghcr.io/${{ steps.repo.outputs.name }}:latest docker.pkg.github.com/${{ steps.repo.outputs.name }}/pull:latest
docker push docker.pkg.github.com/${{ steps.repo.outputs.name }}/pull:latest