Merge pull request #998 from NBISweden/dependabot/docker/production/n… #56
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: Create packages | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
jobs: | |
tag: | |
name: generate tag | |
outputs: | |
part: ${{ steps.generate_tag.outputs.part }} | |
tag: ${{ steps.generate_tag.outputs.tag }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '1' | |
- name: Generate new tag | |
id: generate_tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DEFAULT_BUMP: ${{ github.ref_name == 'develop' && 'patch' || 'minor' }} | |
DRY_RUN: true | |
push_to_registry: | |
strategy: | |
matrix: | |
include: | |
- web_url: "https://urdr.nbis.se" | |
redmine_url: "https://projects.nbis.se" | |
env: "prod" | |
- web_url: "https://urdr-test.nbis.se" | |
redmine_url: "https://urdr-test-redmine.nbis.se" | |
env: "test" | |
needs: tag | |
if: needs.tag.outputs.part != '' | |
name: Push Docker image to Github Container registry | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to the Github Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/nbisweden/urdr | |
ghcr.io/nbisweden/urdr-web | |
- name: Build and push urdr | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./production/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/nbisweden/urdr:${{ matrix.env == 'prod' && needs.tag.outputs.tag || format('{0}-test', needs.tag.outputs.tag) }} | |
ghcr.io/nbisweden/urdr:latest | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
org.opencontainers.image.revision=${{ github.sha }} | |
- name: Build and push urdr-web | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./frontend | |
file: ./production/Dockerfile.nginx | |
build-args: | | |
PUBLIC_API_URL=${{ matrix.web_url }} | |
PUBLIC_REDMINE_URL=${{ matrix.redmine_url }} | |
push: true | |
tags: | | |
ghcr.io/nbisweden/urdr-web:${{ matrix.env == 'prod' && needs.tag.outputs.tag || format('{0}-test', needs.tag.outputs.tag) }} | |
ghcr.io/nbisweden/urdr-web:latest | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
org.opencontainers.image.revision=${{ github.sha }} | |
publish_tag: | |
name: publish tag | |
needs: [push_to_registry, tag] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '1' | |
- name: Push tag | |
id: push_tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CUSTOM_TAG: ${{ needs.tag.outputs.tag }} |