-
Notifications
You must be signed in to change notification settings - Fork 71
135 lines (113 loc) · 4.67 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Publish Docker image
on:
push:
branches: [ main ]
env:
DISTRO: ubuntu
REGISTRY: ghcr.io
LOCAL_IMAGE_NAME: ${{ github.event.repository.name }}/ubuntu
FBPCS_LOCAL_IMAGE_NAME: fbpcs/onedocker
REGISTRY_IMAGE_NAME: ghcr.io/${{ github.repository }}/ubuntu
TEST_REGISTRY_IMAGE_NAME: ghcr.io/${{ github.repository }}/test/ubuntu
PL_CONTAINER_NAME: e2e_pl_container
PA_CONTAINER_NAME: e2e_pa_container
VERSION_TAG: latest-build
COORDINATOR_IMAGE_DEV: ghcr.io/facebookresearch/fbpcs/coordinator:dev
jobs:
test_and_push:
runs-on: [self-hosted, e2e_test_runner]
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build fbpcf docker image
run: |
./build-docker.sh -u
- name: Sanity check fbpcf library (v1)
timeout-minutes: 3
run: |
./run-sanity_check.sh -u -v 1
working-directory: fbpcf/tests/github/
- name: Sanity check fbpcf library (v2)
timeout-minutes: 3
run: |
./run-sanity_check.sh -u -v 2
working-directory: fbpcf/tests/github/
- name: Run Edit Distance E2E Test
timeout-minutes: 10
run: |
./run-edit_distance_validation.sh -u
working-directory: fbpcf/tests/github/
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Clone latest stable fbpcs
run: |
git clone https://github.com/facebookresearch/fbpcs
cd fbpcs
git reset --hard $(curl \
--header 'content-type: application/json' \
"https://api.github.com/repos/facebookresearch/fbpcs/actions/workflows/12965519/runs?per_page=1&status=success&branch=main" | jq \
".workflow_runs[0] .head_sha" | tr -d '"')
- name: Build fbpcs image (this uses the locally built fbpcf image as a dependency)
run: |
cd fbpcs
./build-docker.sh onedocker -t ${{ env.VERSION_TAG }}
- name: Tag fbpcf docker image
run: |
docker tag ${{ env.LOCAL_IMAGE_NAME }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }}
- name: Push fbpcf image to registry
run: |
docker push --all-tags ${{ env.REGISTRY_IMAGE_NAME }}
- name: Create version string
id: create_version
uses: paulhatch/[email protected]
with:
tag_prefix: "v"
major_pattern: "((MAJOR))"
minor_pattern: "((MINOR))"
format: "${major}.${minor}.${patch}-pre${increment}"
- name: Add tag to commit
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.create_version.outputs.version_tag }}
tag_prefix: ""
- name: Set output
id: vars
run: echo "ref=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Pull image for this commit from registry
run: |
docker pull ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }}
- name: Tag Docker image
run: |
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.vars.outputs.ref }}
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.create_version.outputs.major }}
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.create_version.outputs.major }}.${{ steps.create_version.outputs.minor }}
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.create_version.outputs.major }}.${{ steps.create_version.outputs.minor }}.${{ steps.create_version.outputs.patch }}
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.create_version.outputs.version_tag }}
docker tag ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY_IMAGE_NAME }}:latest
- name: Push Docker image
run: |
docker push --all-tags ${{ env.REGISTRY_IMAGE_NAME }}
- name: Create release
uses: "actions/create-release@v1"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: ${{ steps.create_version.outputs.version_tag }}
tag_name: ${{ steps.create_version.outputs.version_tag }}
- name: Cleanup
run: |
# remove all images
docker image prune -af
# stop and remove all containers
docker kill $(docker ps -q) || echo "No running containers to stop."
docker rm $(docker ps -a -q) || echo "No containers to delete."