-
Notifications
You must be signed in to change notification settings - Fork 1
34 lines (30 loc) · 1.21 KB
/
Build_And_Publish_Docker_Images.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
name: Build and publish Docker images
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: enalean/bz2tuleap
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t ${{ env.IMAGE_NAME }} --label revision=${{ github.sha }} --label workflow_run_id=${{ github.run_id }} .
- name: Install Cosign
uses: sigstore/[email protected]
- name: Log into Docker Hub
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u bz2tuleappushbot --password-stdin
- name: Publish image
run: docker push ${{ env.IMAGE_NAME }}
- name: Sign image
env:
VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
run: |
export VAULT_TOKEN=$(curl "$VAULT_ADDR"/v1/auth/approle/login --silent --fail -X POST --data '{"role_id": "${{ secrets.VAULT_ROLE_ID_SIGNING }}", "secret_id": "${{ secrets.VAULT_SECRET_ID_SIGNING }}"}' | jq -r '.auth.client_token')
cosign sign --yes --tlog-upload=true --key hashivault://tuleap-additional-tools-signing "$(docker inspect --format='{{index .RepoDigests 0}}' ${{ env.IMAGE_NAME }})"