Skip to content

Commit da07577

Browse files
committed
Add GHA.
1 parent 6e8c9a9 commit da07577

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 🚀 Deploy
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
6+
permissions:
7+
actions: read
8+
contents: read
9+
id-token: write
10+
packages: write
11+
attestations: write
12+
13+
on:
14+
pull_request:
15+
types: [opened, synchronize, reopened]
16+
push:
17+
branches:
18+
- master
19+
- next_release/*
20+
- release/*
21+
22+
env:
23+
CONTAINER_NAME: ubiqube/msa2-php-sdk-installer
24+
REVIEWERS: msa-api
25+
26+
jobs:
27+
deploy:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Login to GitHub Container Registry
35+
uses: docker/login-action@v3
36+
37+
- name: Docker meta
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: "${{ env.CONTAINER_NAME }}"
42+
tags: |
43+
type=sha,format=long
44+
latest
45+
46+
- name: Build Docker image and publish to Docker Hub
47+
id: push
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
push: ${{ github.event_name != 'pull_request' }}
52+
provenance: mode=max
53+
sbom: true
54+
tags: "${{ steps.meta.outputs.tags }}"
55+
labels: ${{ steps.meta.outputs.labels }}
56+
57+
- name: Set latest commit message as env variable
58+
run: echo "LATEST_COMMIT_MESSAGE=$(git log -1 --oneline ${{ github.event.after }} | sed 's/"/\\"/g')" >> $GITHUB_ENV
59+
60+
- name: Notify msa-docker repo about updated ${{ env.CONTAINER_NAME }} Docker image
61+
uses: benc-uk/workflow-dispatch@v1
62+
with:
63+
token: ${{ secrets.MSA_DOCKER_REPO_ACCESS_TOKEN }}
64+
ref: ${{ github.ref_name || 'master' }}
65+
repo: ubiqube/msa-docker
66+
workflow: create-pr.yml
67+
inputs: |-
68+
{
69+
"image_name": "${{ env.CONTAINER_NAME }}",
70+
"image_tag": "sha-${{ github.sha }}",
71+
"latest_commit_message": "${{ env.LATEST_COMMIT_MESSAGE }}",
72+
"team_reviewers": "${{ env.REVIEWERS }}",
73+
"branch_name": "${{ github.ref_name }}"
74+
}

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM docker.io/ubiqube/msa2-linuxdev:latest AS builder
2+
USER 1000
3+
WORKDIR /home/ncuser
4+
5+
RUN install_default_dirs.sh
6+
7+
COPY . .
8+
# Build tarball {{{
9+
RUN cp -R . /opt/fmc_repository/php_sdk && \
10+
install_repo_deps.sh /opt/fmc_repository/php-sdk && \
11+
echo "⏳ Creating php-sdk-reference.tar.xz" && \
12+
chmod a+w -R /opt/fmc_repository/ && \
13+
tar cf php-sdk-reference.tar.xz --exclude-vcs /opt/fmc_repository/ -I 'xz -T0' --checkpoint=1000 --checkpoint-action=echo='%{%Y-%m-%d %H:%M:%S}t ⏳ \033[1;37m(%d sec)\033[0m: \033[1;32m#%u\033[0m, \033[0;33m%{}T\033[0m'
14+
# }}}
15+
16+
FROM docker.io/ubiqube/ubi-almalinux10:latest
17+
# Copy all resources to the final image {{{
18+
RUN mkdir -p /opt/fmc_repository && chown -R 1000:1000 /opt/fmc_repository
19+
USER 1000
20+
COPY --from=builder /home/ncuser/*.xz /home/ncuser/
21+
COPY --from=builder /usr/share/install-libraries/il-lib.sh /usr/share/install-libraries/il-lib.sh
22+
COPY docker-entrypoint.sh /
23+
COPY install.sh /home/ncuser/
24+
ENTRYPOINT ["/docker-entrypoint.sh"]
25+
# }}}
26+
27+

docker-entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -e
3+
error() {
4+
echo "🎃 Failed !!!"
5+
}
6+
trap error ERR
7+
8+
log_info() {
9+
TIMESTAMP=$(date --iso-8601=ns)
10+
echo -e "$TIMESTAMP | $*"
11+
}
12+
13+
if [[ -n "$ENABLE_K8S" ]];
14+
then
15+
log_info "⏳ Wait for linuxdev."
16+
until nc -zv msa-dev 22; do
17+
sleep 10
18+
log_info "⏳ Wait for linuxdev."
19+
done
20+
fi
21+
cd / || exit 1
22+
23+
if [[ -f /opt/fmc_repository/php_sdk/.git ]]; then
24+
log_info "👾 Skipping upgrade for fellow developer."
25+
exit 0
26+
fi
27+
tar --overwrite --no-same-owner -xf /home/ncuser/php-sdk-reference.tar.xz -I 'xz -T0' --checkpoint=1000 --checkpoint-action=echo='%{%Y-%m-%d %H:%M:%S}t⏳ \033[1;37m(%d sec)\033[0m: \033[1;32m#%u\033[0m, \033[0;33m%{}T\033[0m'
28+
/home/ncuser/install.sh
29+
echo "✅ Sucess ..."
30+
31+

0 commit comments

Comments
 (0)