forked from Anush008/fastembed-js
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (86 loc) · 3.47 KB
/
image.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Create and publish a Docker image
on:
workflow_dispatch:
push:
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ECR_REPOSITORY: nodemodules/fastembed
DOCKER_REPOSITORY: h4ckermike/fastembed-js
SESSION_APP_NAME: fastembed
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Configure AWS credentials
uses: meta-introspector/configure-aws-credentials@v4
with:
aws-region: ${{ secrets.AWS_REGION || 'us-east-2'}}
role-session-name: github-actions-${{ env.SESSION_APP_NAME }}
# FIXME hard coded
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID || '767503528736' }}:role/github
- name: Set up Docker Buildx
uses: meta-introspector/[email protected]
with:
install: true
platforms: linux/amd64,linux/arm/v7,linux/arm/v8
- name: Login to Amazon ECR
id: login-ecr
uses: meta-introspector/amazon-ecr-login@v1
- uses: meta-introspector/create-ecr-repository-action@v1
with:
repository: ${{ env.ECR_REPOSITORY }}
- name: Set short sha
id: sha_short
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: meta-introspector/login-action@v3
with:
username: ${{ vars.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Checkout repository
uses: meta-introspector/checkout@v4
- name: Log in to the Container registry
uses: meta-introspector/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: meta-introspector/[email protected]
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKER_REPOSITORY}}
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY}}
- name: Build and push Docker image
id: push
uses: meta-introspector/[email protected]
with:
platforms: linux/arm64,linux/arm64/v8
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: meta-introspector/attest-build-provenance@local
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
- name: Make Docker image public
run: |
curl \
-X PATCH \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/container/${{ env.IMAGE_NAME }}/visibility \
-d '{"visibility":"public"}'