name: build-image on: push: schedule: - cron: '@monthly' jobs: parse_tag: name: Parse tag from upstream metadata runs-on: ubuntu-latest outputs: version: ${{ steps.tag.outputs.version }} steps: - name: Pull upstream metadata id: tag run: | echo "version=$(curl -IsL https://downloads.filestash.app/upload/enterprise.tar.gz | grep -i "last-modified" | cut -d' ' -f2- | date -f - +%Y%m%d)" >> $GITHUB_OUTPUT - name: Assert tag output run: | [[ -z "${{ steps.tag.outputs.version }}" ]] && { echo 'No release tag - exiting'; exit 1 } || { echo 'Release tag set correctly: ${{ steps.tag.outputs.version }}'; exit 0 } - name: Lookup tag within existing package versions run: | RELEASE_EXISTS=$(curl -s -L 'GET' \ 'https://code.spamasaurus.com/api/v1/packages/djpbessems/container/filestash-enterprise' \ -H 'accept: application/json' \ -H 'Authorization: token ${{ secrets.GIT_APIKEY }}' | \ jq -r 'any(.[].version; . == "${{ steps.tag.outputs.version }}")') [[ "$RELEASE_EXISTS" == "true" ]] && { echo "Version already exists. Skipping build..."; exit 1 } || { echo "Version is new. Proceeding..."; exit 0 } build_container: name: Container image runs-on: ubuntu-latest needs: parse_tag env: DOCKER_HOST: unix:///var/run/docker.sock steps: - name: Check out repository code uses: actions/checkout@v4 - name: Create builder context id: buildx-context run: | docker context create builders - name: Set up buildx id: buildx uses: docker/setup-buildx-action@v3 with: endpoint: builders - name: Login to private repository uses: docker/login-action@v3 with: registry: code.spamasaurus.com username: ${{ secrets.GIT_USERNAME }} password: ${{ secrets.GIT_APIKEY }} - name: Build & push container image uses: docker/build-push-action@v5 with: context: . tags: | code.spamasaurus.com/djpbessems/filestash-enterprise:latest code.spamasaurus.com/djpbessems/filestash-enterprise:${{ needs.parse_tag.outputs.version }} provenance: false push: true # build_chart: # name: Helm chart # runs-on: dind-rootless # needs: semrel_dryrun # steps: # - name: Check out repository code # uses: actions/checkout@v4 # - uses: azure/setup-helm@v4.2.0 # id: setup # with: # version: "latest" # - name: Prepare build environment # run: | # helm plugin install https://github.com/chartmuseum/helm-push # sed -i 's/{{ chart_version }}/${{ needs.semrel_dryrun.outputs.version }}/g' charts/json-server/Chart.yaml # sed -i 's/{{ image_tag }}/${{ needs.semrel_dryrun.outputs.version }}/g' charts/json-server/values.yaml # - name: Build & push helm chart # run: | # helm package ./charts/json-server # helm repo add \ # --username ${{ secrets.GIT_USERNAME }} \ # --password ${{ secrets.GIT_APIKEY }} \ # spamasaurus \ # https://code.spamasaurus.com/api/packages/${{ secrets.GIT_USERNAME }}/helm # helm cm-push \ # json-server-*.tgz \ # spamasaurus