Skip to content

Commit e36a7e0

Browse files
authored
Merge pull request #1390 from danger/revert-1389-revert-1388-build-to-ghcr
Revert "Revert "add build and push to ghcr similar to danger""
2 parents 16be6b6 + a430abd commit e36a7e0

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

.github/workflows/publish_package.yml

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,46 @@ name: Release Danger-JS package
22

33
on:
44
push:
5+
branches:
6+
- 'master'
57
tags:
68
- '*'
79

10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
814
jobs:
915
build:
10-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
1120

1221
steps:
13-
- uses: actions/checkout@v3
14-
15-
- name: Export tag version
16-
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
22+
- name: Checkout
23+
uses: actions/checkout@v3
1724

18-
- name: Docker Login
19-
run: echo $PACKAGES_WRITE_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin
20-
env:
21-
PACKAGES_WRITE_TOKEN: ${{ secrets.DOCKER_GITHUB_PASSWORD }}
22-
USERNAME: ${{ secrets.DOCKER_GITHUB_USERNAME }}
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v2
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
2331

24-
- name: Docker Build
25-
run: docker build -t ghcr.io/danger/danger-js:$VERSION .
32+
- name: Set up Docker metadata
33+
id: meta
34+
uses: docker/metadata-action@v4
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
tags: |
38+
type=ref,event=branch
39+
type=ref,event=tag
2640
27-
- name: Deploy
28-
run: docker push ghcr.io/danger/danger-js:$VERSION
41+
- name: Build and push Docker image
42+
uses: docker/build-push-action@v4
43+
with:
44+
context: .
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)