Skip to content

Commit 90300a5

Browse files
authored
Merge pull request #73 from metacpan/ssoriche/workflows
Enable auto deploy
2 parents 1b53ddd + 6fc59df commit 90300a5

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

‎.github/workflows/build-production-container.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,62 @@ on:
66
- master
77
workflow_dispatch:
88
jobs:
9-
docker:
9+
docker-build:
10+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-container')
1011
runs-on: ubuntu-22.04
11-
name: Docker Push
12+
name: Docker Build and Push
1213
steps:
13-
- uses: actions/checkout@v3
14-
- name: docker build
15-
run: docker build . -t metacpan/metacpan-grep-front-end:latest
14+
- name: Generate Auth Token
15+
uses: actions/create-github-app-token@v2
16+
id: app-token
17+
with:
18+
app-id: ${{ secrets.APP_ID }}
19+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
20+
owner: metacpan
1621
- name: Log in to Docker Hub
17-
uses: docker/login-action@v2
22+
uses: docker/login-action@v3
1823
with:
1924
username: ${{ secrets.DOCKER_HUB_USER }}
2025
password: ${{ secrets.DOCKER_HUB_TOKEN }}
21-
- name: Push build to Docker hub
22-
run: docker push metacpan/metacpan-grep-front-end:latest
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
- uses: actions/checkout@v4
29+
with:
30+
token: ${{ steps.app-token.outputs.token }}
31+
- name: Build test image
32+
id: docker-build-test
33+
uses: docker/build-push-action@v6
34+
with:
35+
target: test
36+
push: false
37+
load: true
38+
- name: Docker meta
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ github.repository }}
43+
flavor: |
44+
latest=false
45+
tags: |
46+
type=sha,format=long,priority=2000,enable={{is_default_branch}}
47+
type=ref,event=branch
48+
type=ref,event=pr
49+
type=raw,value=latest,enable={{is_default_branch}}
50+
env:
51+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
52+
- name: Build and push
53+
uses: docker/build-push-action@v6
54+
with:
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
annotations: ${{ steps.meta.outputs.annotations }}
59+
- name: Update deployed image
60+
if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }}
61+
uses: benc-uk/workflow-dispatch@v1
62+
with:
63+
repo: metacpan/metacpan-k8s
64+
ref: main
65+
workflow: set-image.yml
66+
token: ${{ steps.app-token.outputs.token }}
67+
inputs: '{ "app": "grep", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'

0 commit comments

Comments
 (0)