Update sbt-buildinfo to 0.13.0 (#2118) #3719
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Repository | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- prod | |
- master | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
IMAGE_NAME: aplus | |
jobs: | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
push: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build image | |
run: docker build . --file Dockerfile --tag $IMAGE_NAME | |
# Use login-action to avoid leaking secrets | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.pkg.github.com | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Push image | |
run: | | |
GH_IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
GH_IMAGE_ID=$(echo $GH_IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo GH_IMAGE_ID=$GH_IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_NAME $GH_IMAGE_ID:$VERSION | |
docker push $GH_IMAGE_ID:$VERSION | |
docker tag $IMAGE_NAME betagouv/aplus:$VERSION | |
docker push betagouv/aplus:$VERSION | |
if [ "$VERSION" == "latest" ]; then | |
VERSION=master-$(date +'%Y-%m-%dt%H-%M-%Sz')-$(git rev-parse --short HEAD) | |
echo VERSION=$VERSION | |
docker tag $IMAGE_NAME $GH_IMAGE_ID:$VERSION | |
docker push $GH_IMAGE_ID:$VERSION | |
docker tag $IMAGE_NAME betagouv/aplus:$VERSION | |
docker push betagouv/aplus:$VERSION | |
fi |