Skip to content

Commit

Permalink
Merge pull request #2891 from postalserver/export-branch-to-image
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke authored Mar 20, 2024
2 parents 4d9654d + 1823617 commit 6ef3885
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
VER="$(git describe --tags 2>/dev/null)"
echo "version=${VER}" >> "$GITHUB_OUTPUT"
echo "branch=${REF}" >> "$GITHUB_OUTPUT"
echo 'tags<<EOF' >> "$GITHUB_OUTPUT"
if [[ "$REF" == "main" ]]; then
Expand All @@ -105,6 +106,7 @@ jobs:
platforms: linux/amd64
build-args: |
VERSION=${{ steps.info.outputs.version }}
BRANCH=${{ steps.info.outputs.branch }}
publish-image:
name: Publish Image
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ vendor/bundle

Procfile.local
VERSION
BRANCH

.rubocop-https*
.env*
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ruby:3.2.2-bullseye AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
software-properties-common dirmngr apt-transport-https \
software-properties-common dirmngr apt-transport-https \
&& (curl -sL https://deb.nodesource.com/setup_20.x | bash -) \
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -43,8 +43,10 @@ COPY ./docker/wait-for.sh /docker-entrypoint.sh
COPY --chown=postal . .

# Export the version
ARG VERSION=unspecified
RUN echo $VERSION > VERSION
ARG VERSION=null
ARG BRANCH=null
RUN echo $VERSION > VERSION \
&& echo $BRANCH > BRANCH

# Set paths for when running in a container
ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ def endpoint_options_for_select(server, selected_value = nil, options = {})
end.html_safe
end

def postal_version_string
string = Postal.version
string += " (#{Postal.branch})" if Postal.branch &&
Postal.branch != "main"
string
end

end
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
%footer.siteContent__footer
%ul.footer__links
%li.footer__name
Powered by #{link_to "Postal", "https://postalserver.io", target: '_blank'} #{Postal.version}.
Powered by
#{link_to "Postal", "https://postalserver.io", target: '_blank'}
#{postal_version_string}
%li= link_to "Documentation", "https://docs.postalserver.io", target: '_blank'
%li= link_to "Ask for help", "https://discussions.postalserver.io", target: '_blank'
12 changes: 12 additions & 0 deletions lib/postal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ def change_database_connection_pool_size(new_size)
ActiveRecord::Base.establish_connection(config.merge(pool: new_size))
end

# Return the branch name which created this release
#
# @return [String, nil]
def branch
return @branch if instance_variable_defined?("@branch")

@branch = begin
path = Rails.root.join("BRANCH")
File.read(path).strip if File.exist?(path)
end
end

end

Config = initialize_config
Expand Down

0 comments on commit 6ef3885

Please sign in to comment.