Skip to content

Merge pull request #9 from pddg/dependabot/github_actions/docker/logi… #38

Merge pull request #9 from pddg/dependabot/github_actions/docker/logi…

Merge pull request #9 from pddg/dependabot/github_actions/docker/logi… #38

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: go.mod
- uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
restore-keys: |
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
- uses: aquaproj/aqua-installer@ea518c135a02fc11ff8024364510c181a5c6b342 # v4.0.3
with:
aqua_version: v2.46.0
- name: Run unit tests
run: |
make test
- name: Build all
run: |
make all
make archive
- name: Run e2e tests
run: |
aqua i
make test-e2e
- name: upload e2e test logs
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: e2e/logs
- name: upload build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build
path: build.tar
- uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
if: github.event_name == 'push'
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
build-image:
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: build
- name: Extract artifacts
run: |
tar -xf build.tar
rm -f build.tar
- name: Get photon version
id: photon_metadata
run: |
source .env
echo "version=${PHOTON_VERSION}" >> $GITHUB_OUTPUT
echo "sha256=${PHOTON_SHA256SUM}" >> $GITHUB_OUTPUT
echo "revision=${CONTAINER_REVISION}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to ghcr.io
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine image tags
id: tags
run: |
IMAGE=ghcr.io/pddg/photon
TAG="${{ steps.photon_metadata.outputs.version }}-rev.${{ steps.photon_metadata.outputs.revision }}"
if docker manifest inspect $IMAGE:$TAG > /dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
TAGS="latest"
else
echo "$TAG does not exist. It will be created."
TAGS="$TAG latest"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
for t in $TAGS; do
echo $IMAGE:$t >> $GITHUB_OUTPUT
done
echo "EOF" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
PHOTON_VERSION=${{ steps.photon_metadata.outputs.version }}
PHOTON_SHA256SUM=${{ steps.photon_metadata.outputs.sha256 }}
GIT_SHA=${{ github.sha }}
tags: |
${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [build-image]
permissions:
contents: write
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: build
- name: Extract artifacts
run: |
tar -xf build.tar
rm -f build.tar
- name: create checksum file
run: |
sha256sum build/* > ./checksum.txt
mv ./checksum.txt build/
- name: create release if needs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source .env
TAG="${PHOTON_VERSION}-rev.${CONTAINER_REVISION}"
if [ ! -z "$(git tag -l $TAG)" ]; then
echo "Tag $TAG already exists, skipping"
exit 0
fi
echo "Tag $TAG does not exist. It will be created."
gh release create $TAG \
--title "$TAG" \
--generate-notes \
build/*