Skip to content

Commit 9196168

Browse files
committed
Fix and cleanup devcontainer workflow
1 parent 3e64d44 commit 9196168

1 file changed

Lines changed: 35 additions & 25 deletions

File tree

.github/workflows/devcontainer.yml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,59 @@
11
name: Container
22

33
on:
4-
create:
54
push:
65
branches:
76
- develop
87
tags:
9-
- 'v*'
8+
- "v*"
109
workflow_dispatch:
1110

11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
concurrency:
16+
group: container-${{ github.ref }}
17+
cancel-in-progress: ${{ github.ref == 'refs/heads/develop' }}
18+
1219
defaults:
1320
run:
1421
shell: bash
1522

1623
jobs:
1724
build_container_and_push:
25+
name: Build and push (${{ matrix.dockerfile }})
1826
runs-on: X64
19-
if: github.repository_owner == 'deepmodeling'
27+
28+
if: >-
29+
github.repository == 'deepmodeling/abacus-develop' &&
30+
(github.ref == 'refs/heads/develop' ||
31+
startsWith(github.ref, 'refs/tags/v'))
32+
2033
strategy:
2134
matrix:
22-
dockerfile: ["gnu","intel","cuda"]
23-
steps:
24-
- name: Force Clean Workspace
25-
run: |
26-
sudo chattr -i -R ${{ github.workspace }} 2>/dev/null || true
27-
sudo chown -R $USER:$USER ${{ github.workspace }}
28-
sudo find ${{ github.workspace }} -mindepth 1 -delete
29-
30-
- name: Checkout
31-
uses: actions/checkout@v7
35+
dockerfile:
36+
- gnu
37+
- intel
38+
- cuda
39+
40+
env:
41+
DOCKER_CONFIG: ${{ runner.temp }}/docker-${{ github.run_id }}-${{ matrix.dockerfile }}
3242

33-
- name: Docker meta
43+
steps:
44+
- name: Docker metadata
3445
id: meta
3546
uses: docker/metadata-action@v6
3647
with:
3748
images: |
3849
ghcr.io/deepmodeling/abacus-${{ matrix.dockerfile }}
3950
dp-harbor-registry.us-east-1.cr.aliyuncs.com/deepmodeling/abacus-${{ matrix.dockerfile }}
51+
flavor: |
52+
latest=false
4053
tags: |
41-
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
54+
type=semver,pattern={{version}},value=${{ github.ref_name }},enable=${{ github.ref_type == 'tag' }}
4255
type=raw,value=latest
4356
44-
- name: Fix Docker Directory Permissions
45-
run: |
46-
sudo mkdir -p /home/runner/.docker
47-
sudo chown -R $USER:$USER /home/runner/.docker
48-
4957
- name: Setup Docker Buildx
5058
uses: docker/setup-buildx-action@v4
5159

@@ -60,16 +68,18 @@ jobs:
6068
uses: docker/login-action@v4
6169
with:
6270
registry: dp-harbor-registry.us-east-1.cr.aliyuncs.com
63-
# AliCloud automatically mirrors to registry.dp.tech
71+
# AliCloud automatically mirrors this registry to registry.dp.tech.
6472
username: ${{ secrets.DP_HARBOR_USERNAME }}
6573
password: ${{ secrets.DP_HARBOR_PASSWORD }}
6674

67-
- name: Build and Push Container
75+
- name: Build and push container
6876
uses: docker/build-push-action@v7
6977
with:
70-
tags: ${{ steps.meta.outputs.tags }}
71-
labels: ${{ steps.meta.outputs.labels }}
78+
context: "{{defaultContext}}"
7279
file: Dockerfile.${{ matrix.dockerfile }}
7380
push: true
74-
cache-from: type=registry,ref=ghcr.io/deepmodeling/abacus-${{ matrix.dockerfile }}:latest
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
cache-from: |
84+
type=registry,ref=ghcr.io/deepmodeling/abacus-${{ matrix.dockerfile }}:latest
7585
cache-to: type=inline

0 commit comments

Comments
 (0)