-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (59 loc) · 2.21 KB
/
terraform-modules-oci-release.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
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
name: " Terraform modules release on OCI"
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
on:
workflow_call:
inputs:
runs-on:
required: false
type: string
default: ubuntu-latest
organization_layer_name:
required: false
type: string
default: platform
team_name:
required: true
type: string
products_path:
required: false
type: string
default: "products"
env:
REPOSITORY: "${{ github.event.repository.name }}"
jobs:
build-push:
runs-on: "${{ inputs.runs-on }}"
steps:
- uses: actions/checkout@v2
- uses: sigstore/cosign-installer@main
- uses: fluxcd/flux2/action@main
- name: Prepare tag
id: prepare_tag
run: |
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}
- name: Docker login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish OCI
run: |
ls -la
echo "${{ steps.prepare_tag.outputs.VERSION }}"
basePath="${{ inputs.organization_layer_name }}/${{ inputs.team_name }}/${{ inputs.products_path }}"
for terraformPath in $(find "$basePath" -type d -name 'terraform' -exec dirname {} \; | sed "s|^$basePath/||" | sort | uniq); do
productName=$(echo "$terraformPath" | sed 's/\//-/g')
echo "Publishing $productName"
echo ${{ steps.prepare_tag.outputs.VERSION }} "${basePath}/${terraformPath}/terraform" "${{ inputs.organization_layer_name }}-${{ inputs.team_name }}-${productName}"
# bash -x ./publish-oci.sh ${{ steps.prepare_tag.outputs.VERSION }} "${basePath}/${terraformPath}/terraform" "${{ inputs.organization_layer_name }}-${{ inputs.team_name }}-${productName}"
done
#