-
-
Notifications
You must be signed in to change notification settings - Fork 8
75 lines (72 loc) · 2.59 KB
/
publish-pulumi-oci.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
---
name: Publish Pulumi OCI
on:
workflow_dispatch: {}
push:
branches:
- main
paths:
- infrastructure/pulumi/**
jobs:
changed-files:
name: Generate matrix for building images
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Nix
uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Install tools
uses: workflow/nix-shell-action@v3.4.0
with:
packages: jo
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c # v44.5.7
with:
dir_names: "true"
dir_names_max_depth: "3"
json: "true"
files: |
infrastructure/pulumi/**
- name: List all changed files
run: |
echo '${{ steps.changed-files.outputs.all_changed_files }}'
- name: Store changed projects
id: set-matrix
run: |
if [[ "${{ steps.changed-files.outputs.all_changed_files }}" == "[]" ]]; then
echo "matrix={\"project\":$(find infrastructure/pulumi -type d -mindepth 1 -maxdepth 1 | jo -a)}" >> "${GITHUB_OUTPUT}"
else
echo "matrix={\"project\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "${GITHUB_OUTPUT}"
fi
publish-pulumi-oci:
name: Publish Pulumi OCI
runs-on: ubuntu-latest
needs:
- changed-files
strategy:
matrix: ${{ fromJSON(needs.changed-files.outputs.matrix) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Flux
uses: fluxcd/flux2/action@v2.4.0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish as OCI
run: |
flux push artifact "oci://ghcr.io/budimanjojo/pulumi/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \
--path="./${{ matrix.project }}" \
--source="$(git config --get remote.origin.URL)" \
--revision="$(git branch --show-current)/$(git rev-parse HEAD)"
- name: Tag OCI
run: |
flux tag artifact "oci://ghcr.io/budimanjojo/pulumi/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \
--tag main