diff --git a/.forgejo/workflows/build-images-action/action.yml b/.forgejo/workflows/build-images-action/action.yml index bf3cbd2..0f56f06 100644 --- a/.forgejo/workflows/build-images-action/action.yml +++ b/.forgejo/workflows/build-images-action/action.yml @@ -1,39 +1,11 @@ name: Build Container Images -inputs: - image-prefix: - required: true - registry-user: - required: true - registry-token: - required: true - registry-endpoint: - required: true runs: using: composite steps: - uses: actions/checkout@v4 - name: Setup Spud uses: https://forge.karnov.club/spadinastan/setup-spud-action@feat/install-spud-in-env - - name: Login to Registry - run: podman login -u ${{ inputs.registry-user }} -p ${{ inputs.registry-token }} ${{ inputs.registry-endpoint }} - - name: Set image metadata - id: image-metadata - run: | - echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Build images run: | spud build -d ./service.yml podman image ls - - name: Push tagged images to registry - if: ${{ github.event_name == 'push' }} - run: | - for image in $(podman image ls --format {{.Repository}} | grep localhost/${{ inputs.image-prefix }}) - do - for tag in latest ${{ steps.image-metadata.outputs.image-tag }} ${{ github.ref_name }} - do - SRC=$image:latest - DEST=${{ vars.REGISTRY_ENDPOINT }}/$image:$tag - echo "Pushing $SRC to $DEST" - podman push $SRC $DEST - done - done diff --git a/.forgejo/workflows/build-images.yml b/.forgejo/workflows/build-images.yml index 61d8230..ae39b8e 100644 --- a/.forgejo/workflows/build-images.yml +++ b/.forgejo/workflows/build-images.yml @@ -17,7 +17,9 @@ jobs: needs: [pre-run] runs-on: imagefactory-latest steps: + - uses: actions/checkout@v4 - uses: ./.forgejo/workflows/build-images-action + - uses: ./.forgejo/workflows/push-images with: image-prefix: sesame registry-user: ${{ secrets.REGISTRY_USER }} diff --git a/.forgejo/workflows/push-images/action.yml b/.forgejo/workflows/push-images/action.yml new file mode 100644 index 0000000..f1ca7df --- /dev/null +++ b/.forgejo/workflows/push-images/action.yml @@ -0,0 +1,31 @@ +name: Push Container Images +inputs: + image-prefix: + required: true + registry-user: + required: true + registry-token: + required: true + registry-endpoint: + required: true +runs: + using: composite + steps: + - name: Login to Registry + run: podman login -u ${{ inputs.registry-user }} -p ${{ inputs.registry-token }} ${{ inputs.registry-endpoint }} + - name: Set image metadata + id: image-metadata + run: | + echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Push tagged images to registry + run: | + for image in $(podman image ls --format {{.Repository}} | grep localhost/${{ inputs.image-prefix }}) + do + for tag in latest ${{ steps.image-metadata.outputs.image-tag }} ${{ github.ref_name }} + do + SRC=$image:latest + DEST=${{ inputs.registry-endpoint }}/$image:$tag + echo "Pushing $SRC to $DEST" + podman push $SRC $DEST + done + done