Skip to content

Commit

Permalink
github-action: Store OCI image as artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
osmman committed Jul 22, 2024
1 parent 0f237c9 commit f605f58
Showing 1 changed file with 81 additions and 23 deletions.
104 changes: 81 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ env:
IMG: ttl.sh/securesign/secure-sign-operator-${{github.run_number}}:1h
BUNDLE_IMG: ttl.sh/securesign/bundle-secure-sign-${{github.run_number}}:1h
CATALOG_IMG: ttl.sh/securesign/catalog-${{github.run_number}}:1h
CONTAINER_TOOL: podman

jobs:
build-operator:
name: Build-operator
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
Expand All @@ -41,42 +42,70 @@ jobs:
- name: Build operator container
run: make docker-build docker-push

- name: Save container image
run: podman save -o /tmp/operator-oci.tar --format oci-archive $IMG

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: operator-image
path: /tmp/operator-oci.tar

build-bundle:
name: Build-bundle-image
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Replace images
run: make dev-images && cat internal/controller/constants/images.go

- name: Build operator bundle
run: make bundle bundle-build bundle-push

- name: Save container image
run: podman save -o /tmp/bundle-oci.tar --format oci-archive $BUNDLE_IMG

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bundle-image
path: /tmp/bundle-oci.tar

build-fbc:
name: Build-fbc
runs-on: ubuntu-20.04
needs: build-bundle
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log in to registry.redhat.io
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: registry.redhat.io
auth_file_path: /tmp/config.json

- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: "*-oci.tar"
merge-multiple: true
path: /tmp

- name: Load images
run: podman load -i /tmp/bundle-oci.tar

- name: Install OPM
run: |
make opm
echo "OPM=${{ github.workspace }}/bin/opm" >> $GITHUB_ENV
- name: Checkout FBC source
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: "securesign/fbc"
path: fbc
Expand All @@ -96,23 +125,32 @@ jobs:
cat v4.14/graph.json
${{ env.OPM }} alpha render-template basic v4.14/graph.json > v4.14/catalog/rhtas-operator/catalog.json
${{ env.OPM }} validate v4.14/catalog/rhtas-operator
docker build v4.14 -f v4.14/catalog.Dockerfile -t $CATALOG_IMG
docker push $CATALOG_IMG
podman build v4.14 -f v4.14/catalog.Dockerfile -t $CATALOG_IMG
podman push $CATALOG_IMG
- name: Save container image
run: podman save -o /tmp/catalog-oci.tar --format oci-archive $CATALOG_IMG

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: catalog-image
path: /tmp/catalog-oci.tar

test-kind:
name: Test kind deployment
runs-on: ubuntu-20.04
needs: build-operator
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
Expand All @@ -122,13 +160,23 @@ jobs:
${{ runner.os }}-go-
- name: Log in to registry.redhat.io
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: registry.redhat.io
auth_file_path: /tmp/config.json

- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: "*-oci.tar"
merge-multiple: true
path: /tmp

- name: Load images
run: podman load -i /tmp/operator-oci.tar

- name: Install Cluster
uses: container-tools/[email protected]
with:
Expand Down Expand Up @@ -233,14 +281,14 @@ jobs:
with:
tool-cache: true
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
Expand All @@ -250,15 +298,25 @@ jobs:
${{ runner.os }}-go-
- name: Log in to registry.redhat.io
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: registry.redhat.io
auth_file_path: /tmp/config.json

- name: Image prune
run: docker image prune -af
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: "*-oci.tar"
merge-multiple: true
path: /tmp

- name: Load images
run: |
podman load -i /tmp/operator-oci.tar
podman load -i /tmp/bundle-oci.tar
podman load -i /tmp/catalog-oci.tar
- name: Install Cluster
uses: container-tools/[email protected]
Expand Down Expand Up @@ -353,14 +411,14 @@ jobs:
OIDC_ISSUER_URL: ${{ secrets.testing_keycloak }}
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
Expand Down Expand Up @@ -395,7 +453,7 @@ jobs:
kubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
- name: Log in to registry.redhat.io
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
Expand Down

0 comments on commit f605f58

Please sign in to comment.